Perceived mouse to move into the removal assembly Although starting from D7, adding OneNter and OneXIT events to many components, but for most components, it is still not easy to perceive the mouse to move out of the component. The following method is to solve this problem.
(Effective for general components, invalid for FORM, MainMenu, etc.)
Private {private declarations} // Define two processes: Procedure CmmouseEnter (VAR Msg: TMESSAGE); Message Cm_MouseEnter; Procedure CmmouseEleave (Var Msg: tMemage); Message Cm_MouseLeave;
Procedure TFORM1.CmmouseEnter (VAR Msg: TMESSAGE); VAR AnObject: Tobject; Begin Anobject: = TOBJECT (Msg.lParam); // Button1 is the component to be perceived, can be changed to other components if anobject = Button1 Then Edit1.Text: = 'Mouse enter'; end;
Procedure TForm1.cmmouseleave (VAR Msg: TMESSAGE); VAR AnObject: Tobject; Begin Anobject: = Tobject (msg.lparam); if Anobject = Button1 Then Edit1.Text: = 'mouse Leave';