Note that these functions have only one form of private (that is, they are not allowed to overwrite, but are still in the dynamic table):
Tcontrol =class(tcomponent)Private //15 private message processing, mostly mouse messages. Note that the message function is mostly just an intermediary, and Twincontrol is not rewritten. procedureWmnclbuttondown (varMessage:twmnclbuttondown);messageWm_nclbuttondown; procedureWmlbuttondown (varMessage:twmlbuttondown);messageWm_lbuttondown; procedureWmrbuttondown (varMessage:twmrbuttondown);messageWm_rbuttondown; procedureWmmbuttondown (varMessage:twmmbuttondown);messageWm_mbuttondown; procedureWMLBUTTONDBLCLK (varMESSAGE:TWMLBUTTONDBLCLK);messageWM_LBUTTONDBLCLK; procedureWMRBUTTONDBLCLK (varMESSAGE:TWMRBUTTONDBLCLK);messageWM_RBUTTONDBLCLK; procedureWMMBUTTONDBLCLK (varMESSAGE:TWMMBUTTONDBLCLK);messageWM_MBUTTONDBLCLK; procedureWmlbuttonup (varMessage:twmlbuttonup);messageWm_lbuttonup; procedureWmrbuttonup (varMessage:twmrbuttonup);messageWm_rbuttonup; procedureWmmbuttonup (varMessage:twmmbuttonup);messageWm_mbuttonup; // procedureWmmousemove (varMessage:twmmousemove);messageWm_mousemove; procedureWmmousewheel (varMessage:twmmousewheel);messageWM_MouseWheel; procedureWmcancelmode (varMessage:twmcancelmode);messageWm_cancelmode; procedureWmwindowposchanged (varmessage:twmwindowposchanged);messagewm_windowposchanged;//recalculate maximized minimized limits and docking dimensions procedureWmcontextmenu (varMessage:twmcontextmenu);messageWm_contextmenu;//actually expand the right-click menu, although its subclasses override this function, but instead only help send it (sent to the graphical control, for which it added the right-click menu function). //17 Component Events (mostly simple functions, notification of something, generally no actual content) //cm_ Display function procedureCmvisiblechanged (varMessage:tmessage);messagecm_visiblechanged;//The display property has been changed, so call InvalidateControl to repaint itself. Fixme don't understand why this must be called instead of executing the invalidate function procedureCmenabledchanged (varMessage:tmessage);messagecm_enabledchanged;//all 3 functions simply call invalidate, but note that it is possible to call the invalidate function of a subclass Twincontrol procedureCmfontchanged (varMessage:tmessage);messagecm_fontchanged; procedureCmcolorchanged (varMessage:tmessage);messagecm_colorchanged; procedureCmbidimodechanged (varMessage:tmessage);messagecm_bidimodechanged; procedureCmparentbidimodechanged (varMessage:tmessage);messagecm_parentbidimodechanged; //Color Font procedureCmparentfontchanged (varMessage:tmessage);messagecm_parentfontchanged; procedureCmsysfontchanged (varMessage:tmessage);messagecm_sysfontchanged;//Call SetFont procedureCmparentcolorchanged (varMessage:tmessage);messagecm_parentcolorchanged; procedureCmparentshowhintchanged (varMessage:tmessage);messagecm_parentshowhintchanged;//Call Setshowhint procedureCmhintshow (varMessage:tmessage);messagecm_hintshow; procedureCmhittest (varMessage:tcmhittest);messageCm_hittest;//To test whether mouse messages are working on a child control procedureCmmouseenter (varMessage:tmessage);messageCm_mouseenter;//important interesting, send cm_mouseenter to the parent control, why rely on it to handle? procedureCmmouseleave (varMessage:tmessage);messageCm_mouseleave; procedureCmdesignhittest (varMessage:tcmdesignhittest);messageCm_designhittest;//important5 do nothing, the message result is not processed procedureCmfloat (varMessage:tcmfloat);messagecm_float; procedureCmmousewheel (varMessage:tcmmousewheel);messageCm_mousewheel;//send Cm_mousewheel to parent controlEnd;
Also make a list of its wndproc so that it can handle the message:
procedureTcontrol.wndproc (varmessage:tmessage);varForm:tcustomform; Keystate:tkeyboardstate; Wheelmsg:tcmmousewheel;begin if(csdesigninginchComponentstate) Then beginForm:=getparentform (self); if(Form <>Nil) and(Form.designer <>Nil) andForm.Designer.IsDesignMsg (self, Message) ThenExit//messages are handled by the form End; //forms can handle keyboard messages for the components they own if(Message.msg >= Wm_keyfirst) and(Message.msg <= Wm_keylast) Then beginForm:=getparentform (self); if(Form <>Nil) andForm.wantchildkey (self, Message) ThenExit; End //important graphical controls for mouse handling are here Else if(Message.msg >= Wm_mousefirst) and(Message.msg <= Wm_mouselast) Then begin //If the component cannot accept and process the double-click message, it will double-click the message to map to the clicked message. if not(CsdoubleclicksinchControlStyle) Then CaseMessage.msg ofwm_lbuttondblclk, WM_RBUTTONDBLCLK, Wm_mbuttondblclk:dec (message.msg, WM_LBUTTONDBLCLK-wm_lbuttondown); End; CaseMessage.msg ofWM_MOUSEMOVE:Application.HintMouseMessage (self, Message);//if the mouse is moving the message, the Hint window appearsWm_lbuttondown, WM_LBUTTONDBLCLK://If the left button is pressed, or double-clicked, if it is auto-drag mode, start dragging, and the left-click state is added to the state of the component. begin ifFdragmode = dmautomatic Then beginBeginautodrag; Exit; End; Include (Fcontrolstate, Cslbuttondown); //important adds a mouse click state to a graphical control (or to a win control). Clicking on the button will execute here. End; Wm_lbuttonup:exclude (Fcontrolstate, Cslbuttondown); //If the left button is released, the left-click state is removed. Else withMouse Do ifWheelpresent and(Regwheelmessage <>0) and //if the mouse has a scroll wheel and the wheel slides, a message is sent(message.msg = regwheelmessage) Then begingetkeyboardstate (KeyState);//API to copy the state of the 256 virtual keys into the cache withWheelmsg Do //Populating Records beginMSG:=message.msg; Shiftstate:=keyboardstatetoshiftstate (KeyState); Wheeldelta:=Message.wparam; Pos:=Tsmallpoint (Message.lparam); End; Mousewheelhandler (Tmessage (wheelmsg)); //class functions, distributing messages for the mouse wheelExit; End; End; End Else ifMessage.msg = cm_visiblechanged Then withMessage Dosenddocknotification (MSG, WParam, LParam); Dispatch (Message); //here, the WndProc method can no longer be used to pass messages to the parent class, so use dispatch. and must be passed up (in general, the parent class of Tcontrol does not respond to these messages)End;
Tcontrol's message coverage function Daquan (15 wm_ functions and 17 cm_ functions, its WndProc handles mouse and keyboard messages)