代码之家  ›  专栏  ›  技术社区  ›  DeCoder

按名称捕获Windows注册邮件

  •  0
  • DeCoder  · 技术社区  · 9 年前

    在Windows平板电脑上有两个屏幕键盘应用程序(据我所知),c:\program files\common files\microsoft shared\ink\tabtip.exe 和C:\Windows\System32\OSK.exe。

    然后我可以检查IsIconic作为保险,尽可能了解键盘处于什么状态,以便相应地调整我的应用程序显示。

    使用spy++我捕获了TabTip的以下消息:

    <000050>00130426 P消息:0xC298[已注册:“沉浸式聚焦通知”]wParam:FFFFFFF C LPRAM:00000000

    <

    <000052>00130426 P消息:0xC061[已注册:“TabletInputPanelOpen”]wParam:00000000 LPRAM:00000000

    我认为有一个Windows API调用,可以让我在应用程序的窗口过程中向操作系统注册接收这些消息,或者使用消息处理程序获取通知,但我似乎找不到它。

    虽然这些消息在spy++中显示在我的应用程序的消息队列中,但我似乎无法在WindowProc中识别它们,而且Delphi不允许我为这些消息id指定消息处理程序,这些消息id在49xxx范围内。

    有人知道如何按姓名注册这些邮件吗?我认为这是可能的,通过像这样的字符串

    表输入面板打开

    或

    TipCloseMenus

    因此,当操作系统以该名称处理消息时,我的应用程序可以接收/处理它?

    更新: 应用程序。在消息处理程序中,如果忽略消息发送到的句柄,则可以接收消息。我假设这意味着这是广播消息(?)。

    我仍然需要知道如何注册以接收以下消息:

    1) 通过PostMessage或SendMessage发送

    2) 使用RegisterWindowMessage与系统一起建立

    3) 具有标识消息的命名常量,例如“TipCloseMenus”或“TaskbarCreated”

    更新#2: 我发现了一个旧示例,它显示RegisterWindowMessage和GetClipboardFormatName似乎使用相同的内部表来存储已注册的窗口消息和剪贴板格式。使用TMsg调用GetClipboardFormatName。message作为参数查找messageid的标签。显然,在某种程度上,这些消息存储在同一个内部表中。下面是一些示例代码来说明:

    function GetRegisteredWindowMessageLabel(var Msg: TMsg): UnicodeString;
    var
      ay: array[0..99] of Char;
      i: Integer;
    begin
      Result := '';
      if (Msg.message <= $FFFF) and (Msg.message >= $C000) then
      begin
        i := GetClipboardFormatName(Msg.message,ay,Pred(SizeOf(ay)));
        if i > 0 then
          Result := StrPas(ay);
      end;
    end;
    

    谢谢

    1 回复  |  直到 9 年前
        1
  •  1
  •   Remy Lebeau    9 年前

    不能为已注册消息编写编译时消息处理程序,因为它们不使用静态消息ID。你必须打电话 RegisterWindowMessage() 在运行时,然后使用注册的ID过滤接收到的消息,例如:

    var
      msgImmersiveFocusNotification: UINT = 0;
      msgTipCloseMenus: UINT = 0;
      msgTabletInputPanelOpening: UINT = 0;
      msgTaskbarCreated: UINT = 0;
    
    procedure TMainForm:FormCreate(Sender: TObject);
    begin
      msgImmersiveFocusNotification := RegisterWindowMessage('ImmersiveFocusNotification');
      msgTipCloseMenus := RegisterWindowMessage('TipCloseMenus');
      msgTabletInputPanelOpening := RegisterWindowMessage('TabletInputPanelOpening');
      msgTaskbarCreated := RegisterWindowMessage('TaskbarCreated');
    end;
    
    procedure TMainForm.WndProc(var Message: TMessage);
    begin
      inherited;
      if (msgImmersiveFocusNotification <> 0) and (Message.Msg = msgImmersiveFocusNotification) then
      begin
        //...
      end
      else if (msgTipCloseMenus <> 0) and (Message.Msg = msgTipCloseMenus) then
      begin
        //...
      end
      else if (msgTabletInputPanelOpening <> 0) and (Message.Msg = msgTabletInputPanelOpening) then
      begin
        //...
      end
      else if (msgTaskbarCreated <> 0) and (Message.Msg = msgTaskbarCreated) then
      begin
        //...
      end;
    end;