Use application. onmessage to respond to a message:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; Procedure formcreate (Sender: tobject); {This custom process must be integrated with the application. onmessage parameter format} procedure mymessage (var msg: tagmsg; var handled: Boolean); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); begin memo1.clear; application. onmessage: = mymessage; {make application. onmessage execution custom process} end; {response to all messages other than wm_mousemove} procedure tform1.mymessage (var msg: tagmsg; var handled: Boolean); begin if MSG. message wm_mousemove then memo1.lines. add ('$' + inttohex (MSG. message, 4); end.
To respond to a message through tapplicationevents, you must add the tapplicationevents component during design and add onmessage events to it:
unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, appevets; type tform1 = Class (tform) memo1: tmemo; applicationevents1: tapplicationevents; Procedure formcreate (Sender: tobject); Procedure applicationevents1message (var msg: tagmsg; var handled: Boolean); end; vaR form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); begin memo1.clear; end; {response to all messages other than wm_mousemove} procedure tform1.applicationevents1message (var msg: tagmsg; var handled: Boolean ); begin if MSG. message wm_mousemove then memo1.lines. add ('$' + inttohex (MSG. message, 4); end.