| 摘 要:如何用一個(gè)程序截獲管理Windows的消息 關(guān)鍵字:Windows 消息 監(jiān)聽(tīng) 列表 類 別:系統(tǒng)控制 | |
| 有時(shí)候我們?yōu)榱硕囗?xiàng)應(yīng)用而要管理Windows的消息。我們?cè)鯓硬拍茏龅侥兀?BR> { 這個(gè)例子定義的程序可以收取所有發(fā)往主窗口的消息 } Unit TesteandoEsta; Interface Uses SysUtils, WinTypes, WinPRocs, Messages, Classes, Graphics, Controls, Forms, Dialogs, Menus; Type TForm1 = Class (TForm) Private {Private declarations} Public {Public declarations} Procedure WinMsg (Var Msg : TMsg; Var Handled : Boolean); End; Var Form1 : TForm1; Implementation {$R *.DFM} { 所有發(fā)送到主窗體的消息,保存在變量Msg中。 } Procedure TForm1.WinMsg (Var Msg : TMsg; Var Handled : Boolean); Begin If Msg.Message = WM_SYSCOMMAND Then Beep; { 接收到消息時(shí)的通知} End; Procedure TForm1.FormCreate (Sender : TObject); Begin application.OnMessage := WinMsg; { 替換消息句炳} End; | |
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注