2011-01-10 112 views
1

我試圖讓每個窗口消息告訴用戶已經觸摸屏幕。它在任何地方都可以工作,除了按鈕,當它被禁用時。看起來應用程序在點擊禁用控件時沒有收到任何消息。在Windows CE上的.NET CF - 過濾系統消息的問題

我使用OpenNetCF應用2類過濾消息:

Application2.AddMessageFilter(Device.PowerManager);
Application2.Run(new MainForm());

PowerManager的類包含一個下面的方法(所要求的IMessageFilter接口):在日誌文件中有

public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) 
    { 
     log.DebugFormat("windows message {0} - 0x{0:X}", m.Msg); 
     if (m.Msg == 0x0201 || m.Msg == 0x8001 || m.Msg == 0x0005) 
     {     
      return this.ResetPowerManager();  
     } 

     return false; 
    } 

點擊禁用按鈕時沒有指示窗口消息。 我想知道它怎麼可能,我怎樣才能得到這個消息。

回答

1

對於這種情況,可以使用Win32 API函數SetCapture。您可以將主窗體的句柄傳遞給它,它將捕獲所有鼠標事件,直到您致電ReleaseCapture