Delphi - the mouse to scroll up and down the underlying message events

Delphi to achieve grab the mouse to scroll up and down and deal with the underlying message

A few days ago as customers demand: due to personal PC interface restrictions, sometimes Electronic Document display incomplete, hopes the mouse to scroll up and down to control the zooming in and out of the electronic image file.

Following a test by Demo to explain.

WinFrm a new application, add a RzMemo, ApplicationEvents control, as shown below.

 

Add ApplicationEvents control OnMessage event, the key code is as follows:

. 1  Procedure TForm1.ApplicationEvents1Message ( var Msg: tagMSG;
 2    var the Handled: Boolean);
 . 3  the begin 
. 4    // When mouse wheel event occurs on RzMemo1 
. 5    IF (RzMemo1.Focused) and (. Msg Message = the WM_MOUSEWHEEL) the then 
. 6    the begin 
. 7      IF msg.wParam> 0  the then  // roll on 
. 8      the begin 
. 9        RzMemo1.Lines.Add ( ' scroll + 1'd - ' + the FormatDateTime ( ' YYYY-the mM-DD HH: mm: SS ZZZ ' , Now ()));
10      End 
. 11      the else  // the roller 
12 is      the begin 
13 is        RzMemo1.Lines.Add ( ' the roller -1 - ' + the FormatDateTime ( ' YYYY-the MM-DD HH: mm: SS ZZZ ' , Now ()));
 14      End ;
 15      the Handled: = True; // message has been processed 
16    End ;
 . 17  End ;

The following operating results, related news triggered when the mouse to scroll up and down:

 

In summary, we can point at two key judgments, add business logic to achieve what you want to achieve on the mouse to scroll capture and secondary treatment of the underlying message up and down.

 

Guess you like

Origin www.cnblogs.com/jeremywucnblog/p/11489865.html