Form skin implementation-redraw form non-client area (ii)

Source: Internet
Author: User

The first one implements the basic processing. The width of the form border is somewhat enlarged and needs to be thin.

Realize:

1, change the width of the frame line (wm_nccalcsize)

2. Change the frame style (wm_windowposchanging)

The purpose can be achieved by wm_nccalcsize messages.

procedureWmnccalcsize (var message: Twmnccalcsize);messagewm_nccalcsize;procedureTtest.wmnccalcsize (var message: twmnccalcsize);ConstSize_border=5; Size_caption= -;begin//Change the frame size withTwmnccalcsize (Message). calcsize_params^.rgrc[0] Do  beginInc (left, size_border);    INC (Top, size_caption);    Dec (right, size_border);  Dec (Bottom, Size_border); End; Message.result:=0; Handled:=True;End;

The presentation style of the four corners of the form can be seen as the interface outline of XP. The amplitude of the chamfer is slightly smaller.

Adjusting the frame style needs to be handled when the form changes size, and this method can also implement irregular forms.

wm_windowposchanging This message can be fulfilled.

Handling is a problem to be aware of:

1, because is in the adjustment process the actual form dimension is unable to obtain the adjusted state through the getwindowrect This function, therefore needs to save has this message to produce the form adjusts the size information.

2, this message will have many patterns, the trigger source of this message SetWindowPos can set a lot of parameters. We only need to deal with the form changing the size of the mode, other needs to be handled by the system default.

Call control default Message handling

procedureTtest.calldefaultproc (var message: tmessage);begin///  ///Call control default message handling fault///To prevent circular calls, you need to use state control (FCALLDEFAULTPROC)///ifFcalldefaultproc ThenFcontrol.windowproc (message)  Else  beginFcalldefaultproc:=True; Fcontrol.windowproc (message); Fcalldefaultproc:=False; End;End;

Record form position and dimensions, and adjust the form to the frame style

procedureTtest.wmwindowposchanging (varmessage:twmwindowposchanging);varBchanged:boolean;begin///by the external priority processing message, complete the following default control Calldefaultproc (tmessage (message)); Handled:=True; Bchanged:=False; ///Prevent nestingifFchangesizecalled ThenExit; ///Adjust form outer frame///You need to regenerate the form's outer border area if the form size is adjusted. ///if(Message.windowpos^.flags andSwp_nosize =0)or(Message.windowpos^.flags andSwp_nomove =0) Then  begin    if(Message.windowpos^.flags andSwp_nomove =0) Then    beginFleft:=message.windowpos^.x; Ftop:=message.windowpos^.y; End; if(Message.windowpos^.flags andSwp_nosize =0) Then    beginbchanged:= ((message.windowpos^.cx <> fwidth)or(message.windowpos^.cy <> fheight)) and(Message.windowpos^.flags andSwp_nosize =0); Fwidth:=message.windowpos^.cx; Fheight:=message.windowpos^.cy; End; End; if(Message.windowpos^.flags andSwp_framechanged <>0) Thenbchanged:=True; //make adjustments and redraw processingifBchanged Then  beginchangesize;  Invalidatenc; End;End;

Adjust the form style

1 procedurettest.changesize;2 var3 Htmp:hrgn;4 begin5///Adjust the form style6Fchangesizecalled: =True;7   Try8Htmp: =fregion;9     TryTen///creates a rectangular region with a chamfer of 3.  One///The creation of an irregular interface can be achieved here, and the drawing area can be created by BMP A/// -///Note: -///The HRGN handle is a graphical object, a resource managed by window, and a memory leak will occur without releasing the///consequences, you know.  -Fregion: = CreateRoundRectRgn (0,0, Fwidth, Fheight,3,3); - SetWindowRgn (Handle, fregion, True); -     finally +       ifHtmp <>0  Then -DeleteObject (HTMP); //Freeing Resources +    End; A   finally atFchangesizecalled: =False; -   End; - End;

The final effect of the adjustment, thin body feel good still is exquisite.

Code Download: Testcaptiontoolbar (v0.2). 7z

Http://pan.baidu.com/s/1jG64aFW

https://github.com/cmacro/simple

Form skin implementation-redraw form non-client area (ii)

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.