Home > Net >  The WM_NCCALCSIZE problems
The WM_NCCALCSIZE problems

Time:11-27

I rewrote the window CreateParams method
 
Protected override CreateParams CreateParams
{
The get
{
CreateParams cp=base. CreateParams;
Cp. Style=cp. Style | 0 x20000 | 0 x00040000;//allow minimize operation;
Return the cp;
}
}

Specific meaning is 0 x20000=allow task bar click window TAB to maximize minimize window
0 x00040000 said with a thick border, concrete thickness should be up and down six pixels around each
After I stopped in the WndProc WM_NCCALCSIZE message, make the six pixels redrawing borders are not system, make the interface seems to be no border, and can make the system run according to the frame window, let the window to receive the news of a frame window

Caused some problems, however, is when I in the task bar, click on the window tag minimize interface display or, when the window to show that the height and width of the window will automatically increase, increase the height and width of the looks is 6 * 2 pixels, as if I stopped after the WM_NCCALCSIZE message, the system automatically put up and down the borders, left and right borders are appended to the bottom and right, a mystery, I finally got under way on the Internet, to see someone say:
 
If (m. Param!=IntPtr. Zero)
{
NCCALCSIZE_PARAMS rcsize=(NCCALCSIZE_PARAMS) Marshal. PtrToStructure (m.L Param, typeof (NCCALCSIZE_PARAMS));
AdjustClientRect (ref rcsize. RcNewWindow);
Marshal. StructureToPtr (rcsize, m.L Param, false);
}
The else
{
The RECT rcsize=(the RECT) Marshal. PtrToStructure (m.L Param, typeof (the RECT));
AdjustClientRect (ref rcsize);
Marshal. StructureToPtr (rcsize, m.L Param, false);
}


The RECT structure:
 
Public struct the RECT
{
Public int Left;//the left coordinates
Public int Top;//the coordinates on
Public int Right;//the most right coordinate
Public int Bottom;//the bottom coordinates
}


NCCALCSIZE_PARAMS structure:
 
Struct NCCALCSIZE_PARAMS
{
Public the RECT rcNewWindow;
Public the RECT rcOldWindow;
Public the RECT rcClient;
IntPtr lppos;
}


AdjustClientRect methods:
 
Private void AdjustClientRect (ref the RECT rc)
{
Rc. Left +=6;
Rc. Right -=6;
Rc. Top +=6;
Rc. Bottom -=6;
}


But at the end of the run will in each time you click on the task bar tags automatically increase window width is high, have no choice, forget the great god, please grant instruction, Win32 Api is difficult at the moment

CodePudding user response:

no one will be?

CodePudding user response:

With the WM_NCACTIVATE message,

 
Case WM_CREATE message handler:
Case WM_NCCALCSIZE:
Case WM_NCACTIVATE:
{
The RECT rcClient;
GetWindowRect (hWnd, & amp; RcClient);

//Inform the application of the frame change.
SetWindowPos (hWnd,
NULL,
RcClient left, rcClient. Top,
RcClient. Right - rcClient. Left, rcClient bottom - rcClient. Top,
SWP_FRAMECHANGED);

} break;

CodePudding user response:

I can't, I compiled under your code, executable program interface have been redrawn, and see the interface

CodePudding user response:

quoted the ancient farming reply: 3/f
I can't, I compiled under your code, executable program interface have been redrawn, and can't see the interface


This is the cover of the code of the client area with rectangle of the client area, slightly adjusted according to your code,
  •  Tags:  
  • C#
  • Related