Wolfgang Chien's Homepage | Delphi學習筆記 - 問答篇 |
我用Delphi的 new application做了一個MDI的程式,我想讓滑鼠在子視窗的位置能在主視窗的statusbar顯示出來。
問題是當滑鼠在子視窗移動時主視窗無法收到MouseMove 的event,我要如何才能讓主視窗收到子視窗的MouseMove event並且得知滑鼠座標呢?
請使用 Application.OnMessage 這個事件並參考OnLine Help中的說明.
以下有一個實例:
![]() |
1. 在 Form1 置入一 TPanel 備用, TForm1(MDI主視窗類別) 的 public 宣告以下的程序:
... public { Public declarations } ... procedure AppMsg(var Msg: TMsg; var Handled: Boolean); ... end; |
![]() |
2. Form1 的 OnCreate 事件與 AppMsg 的實作程式:
procedure TForm1.AppMsg(var Msg: TMsg; var Handled: Boolean); begin if Msg.Message = WM_MOUSEMOVE then begin Panel1.Caption := IntToStr(LOWORD(Msg.lParam)) + ', ' + IntToStr(HIWORD(Msg.lParam)); end; end; procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMessage := AppMsg; end; |
首頁 | 學習筆記 | 主題公園 | 軟體下載 | 關於本站 | 討論信群 | 相約下次 |