Modify the non-customer partition size of the form and change the height of the Form title bar

Source: Internet
Author: User

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.

  1. /*************************************** ***************************** 
  2. '** [Function name:] onnccalcsize 
  3. '** [Parameter:] wparam, lparam window additional parameter 
  4. '** [Return Value :] 
  5. '** [Author:] Ai Jun 
  6. '** [Date :] 
  7. '** [Global variables :] 
  8. '** [Function Description:] changes the non-customer partition size of the form. 
  9. '*************************************** *****************************/
  10. LresultCdrawfrmwnd: onnccalcsize (WparamWparam,LparamLparam)
  11. {
  12. LongRet = use_default_wnd_proc;
  13. Rect oldrect;
  14. Nccalcsize_params far * lpncsp = NULL;
  15. If((Bool) Wparam)
  16. {
  17. Lpncsp = (nccalcsize_params far *) lparam;
  18. If(Null = lpncsp)
  19. ReturnUse_default_wnd_proc;
  20. Memcpy (& oldrect, & lpncsp-> rgrc [0],Sizeof(Oldrect ));// Save the value of rgrc [0]
  21. // M_wndoldproc pointer of the original form port processing process
  22. // M_hwnd: the handle of the control or form to be modified
  23. // Let the default function handle it first
  24. Ret =: callwindowproc (m_wndoldproc, m_hwnd, wm_nccalcsize, wparam, lparam );
  25. Memcpy (& lpncsp-> rgrc [0], & oldrect,Sizeof(Oldrect ));
  26. // 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.
  27. // Bottom and right are subtracted, and Subtraction is Addition
  28. Lpncsp-> rgrc [0]. Top + = 10;
  29. Lpncsp-> rgrc [0]. Bottom-= 10;
  30. Lpncsp-> rgrc [0]. Left + = 10;
  31. Lpncsp-> rgrc [0]. Right-= 10;
  32. Memcpy (& lpncsp-> rgrc [1], & lpncsp-> rgrc [0],Sizeof(Lpncsp-> rgrc [0]);
  33. Ret = wvr_validrects;//
  34. }
  35. ReturnRET;// Process callwindowproc
  36. }

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.