Message (Three ways to intercept logged messages) for window functions when creating empty windows

Source: Internet
Author: User

A Button1 and Panel1 are placed on the new form, and only FORM1 receive the following message:

procedureTwincontrol.defaulthandler (varMessage);begin  ifFhandle <>0  Then  begin     withTmessage (Message) Do    begin      if(MSG = wm_contextmenu) and(Parent <>Nil) Then      beginResult:=Parent.perform (MSG, WParam, LParam); ifResult <>0  ThenExit; End;  CaseMsg ofWm_ctlcolormsgbox. Wm_ctlcolorstatic:result:= SendMessage (LParam, Cn_base +MSG, WParam, LParam); Cn_ctlcolormsgbox. Cn_ctlcolorstatic:beginSetTextColor (WParam, Colortorgb (Ffont.color));            SetBkColor (WParam, Colortorgb (Fbrush.color)); Result:=Fbrush.handle; End; Else        ifMSG = Rm_getobjectinstance ThenResult:=Integer (self)Else        begin          ifMSG <> WM_PAINTthen //The breakpoint here, unexpectedly received 36 129 70 131 71 3 5 127 1 124 125 48 128 241 Big string of messages Result:=CallWindowProc (Fdefwndproc, Fhandle, MSG, WParam, LParam); End; End; ifMSG = Wm_settext Thensenddocknotification (MSG, WParam, LParam); End; End  Else    inheritedDefaultHandler (Message);End;

Need to study ...

procedureTwincontrol.defaulthandler (varMessage);begin  ifFhandle <>0  Then  begin     withTmessage (Message) Do    begin      if(MSG = wm_contextmenu) and(Parent <>Nil) Then      beginResult:=Parent.perform (MSG, WParam, LParam); ifResult <>0  ThenExit; End;  CaseMsg ofWm_ctlcolormsgbox. Wm_ctlcolorstatic:result:= SendMessage (LParam, Cn_base +MSG, WParam, LParam); Cn_ctlcolormsgbox. Cn_ctlcolorstatic:beginSetTextColor (WParam, Colortorgb (Ffont.color));            SetBkColor (WParam, Colortorgb (Fbrush.color)); Result:=Fbrush.handle; End; Else        ifMSG = Rm_getobjectinstance ThenResult:=Integer (self)Else        begin          ifSelf. Name='Panel1'  Then          begintag:= -; //Here the breakpoint End; ifMSG <> WM_PAINT ThenResult:=CallWindowProc (Fdefwndproc, Fhandle, MSG, WParam, LParam); End; End; ifMSG = Wm_settext Thensenddocknotification (MSG, WParam, LParam); End; End  Else    inheritedDefaultHandler (Message);End;

In this way, you can get all the default messages received by Panel1, and they are all messages that are not normally noticed. You can also record messages in DispatchMessage, which is more clean sweep. You can also record messages in the WndProc, anyway all messages have first passed here.

Two other kinds of infrequently used: using Tappevent and Hookmessage

Message (Three ways to intercept logged messages) for window functions when creating empty windows

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.