Http://blog.csdn.net/testcs_dn/article/details/7644410
To modify a non-customer partition of a form, you must first understand why you want to modify a non-customer partition and what a non-customer partition is.
From the form or control point of view, a non-customer area means that the control area cannot be placed, such as the form title bar, and border. The menu bar is also a non-customer area, and the menu bar is not drawn by the control.
The border of the text box. the scroll bar areas are non-customer areas.
Why do we need to modify non-customer zones ??
The reason is to make the border look better, for example, to add a high form title bar, you need to change the non-customer area, the self-painting non-customer area will respond to the wm_ncpaint message
In this message, you can customize forms, controls, and non-customer areas.
Okay. Now, we need to handle wm_nccalcsize to modify the non-customer size.
You can go to www.panshsoft.com to query the wm_nccalcsize message.
The following isCodeThe function has obtained the value of the wparam lparam parameter. For example, the code in the skin replacement product on my website is called through subclass.
-
- /*************************************** *****************************
-
- '** [Function name:] onnccalcsize
-
- '** [Parameter:] wparam, lparam window additional parameter
- '** [Return Value :]
-
- '** [Author:] Ai Jun
-
- '** [Date :]
-
- '** [Global variables :]
-
- '** [Function Description:] changes the non-customer partition size of the form.
-
- '*************************************** *****************************/
-
- LresultCdrawfrmwnd: onnccalcsize (WparamWparam,LparamLparam)
-
- {
-
- LongRet = use_default_wnd_proc;
- Rect oldrect;
-
-
- Nccalcsize_params far * lpncsp = NULL;
-
-
-
- If((Bool) Wparam)
-
- {
-
- Lpncsp = (nccalcsize_params far *) lparam;
-
-
- If(Null = lpncsp)
- ReturnUse_default_wnd_proc;
-
-
- Memcpy (& oldrect, & lpncsp-> rgrc [0],Sizeof(Oldrect ));// Save the value of rgrc [0]
-
-
- // M_wndoldproc pointer of the original form port processing process
-
- // M_hwnd: the handle of the control or form to be modified
- // Let the default function handle it first
-
- Ret =: callwindowproc (m_wndoldproc, m_hwnd, wm_nccalcsize, wparam, lparam );
-
-
-
- Memcpy (& lpncsp-> rgrc [0], & oldrect,Sizeof(Oldrect ));
-
-
- // Set the non-customer zone as a form or control. Add 10 pixels of non-customer zone to the upper, lower, left, and right sides.
- // Bottom and right are subtracted, and Subtraction is Addition
-
- Lpncsp-> rgrc [0]. Top + = 10;
-
- Lpncsp-> rgrc [0]. Bottom-= 10;
-
- Lpncsp-> rgrc [0]. Left + = 10;
-
- Lpncsp-> rgrc [0]. Right-= 10;
-
-
- Memcpy (& lpncsp-> rgrc [1], & lpncsp-> rgrc [0],Sizeof(Lpncsp-> rgrc [0]);
-
- Ret = wvr_validrects;//
-
- }
-
-
- ReturnRET;// Process callwindowproc
-
- }
In this way, the control or form is added with 10 pixels on the basis of the original non-customer zone. Then, the operating system will respond to the wm_ncpaint message and you will be able to re-paint it.
Nccalcsize_params struct
Nccalcsize_params
the nccalcsize_params structure contains the information available when the application Program processes the wm_nccalcsize message to calculate the size and position of the window's customer zone, and valid content.
typedef struct _ nccalcsize_params {
rect rgrc [3];
pwindowpos lppos;
}nccalcsize_params, * lpnccalcsize_params;
member
· rgrc
rectangular array.
the first rectangle contains the new coordinates after the window is moved or changed. That is, it is the suggested new window coordinate.
the second rectangle contains the coordinates before the window is moved or changed.
the third includes the customer zone coordinates before the window is moved or changed.
If the window is a child window, the coordinates are relative to the customer area of the parent window. If the window is a top-level window, the coordinates are relative to the screen origin.
· lppos
pointer to the windowpos structure. This structure contains the size and position specified when the window is moved or changed.