Windows CE上的.NET CF - 过滤系统消息的问题

时间:2011-01-10 15:50:35

标签: .net compact-framework windows-ce windows-messages

我正在尝试获取每条Windows消息,告知用户已触摸屏幕。它被禁用时,除了按钮以外的任何地方都可以使用。似乎应用程序在单击禁用控件时不会收到任何消息。

我正在使用OpenNetCF Application2类来过滤消息:

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;
    }

在日志文件中,单击禁用按钮时没有指示Windows消息。 我想知道它是如何可能的,我怎么才能收到这条消息。

1 个答案:

答案 0 :(得分:1)

对于此方案,可以使用Win32 API函数SetCapture。您可以将主表单的句柄传递给它,它将捕获所有鼠标事件,直到您调用ReleaseCapture