zoukankan      html  css  js  c++  java
  • TWinControl.DefaultHandler处理WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC消息的两个参数很有意思,两个都是传递句柄

    procedure TWinControl.DefaultHandler(var Message);
    begin
      if FHandle <> 0 then
      begin
        with TMessage(Message) do
        begin
          if (Msg = WM_CONTEXTMENU) and (Parent <> nil) then
          begin
            Result := Parent.Perform(Msg, WParam, LParam);
            if Result <> 0 then Exit;
          end;
          case Msg of
            WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC:
              Result := SendMessage(LParam, CN_BASE + Msg, WParam, LParam); // 它的LParam是一个句柄,它的WParm是一个HDC(可以看SetBkColor的MSDN说明),消息本身只被用来做转换,然后被丢弃
            CN_CTLCOLORMSGBOX..CN_CTLCOLORSTATIC:
              begin
                SetTextColor(WParam, ColorToRGB(FFont.Color));
                SetBkColor(WParam, ColorToRGB(FBrush.Color));
                Result := FBrush.Handle;
              end;
          else
            if Msg = RM_GetObjectInstance then
              Result := Integer(Self)
            else
            begin
              if Msg <> WM_PAINT then
              Result := CallWindowProc(FDefWndProc, FHandle, Msg, WParam, LParam);
            end;
          end;
          if Msg = WM_SETTEXT then
            SendDockNotification(Msg, WParam, LParam);
        end;
      end
      else
        inherited DefaultHandler(Message);
    end;

    但是我搞不明白WM_CTLCOLORMSGBOX本身是不是标准Windows消息呢?好像是,但是不能在MSDN中直接查到,只能从许多VC的文章里间接的见到。

    https://msdn.microsoft.com/fr-fr/library/cc485255(v=vs.71).aspx

    但是WM_CTLCOLORSTATIC是Windows标准消息:
    https://msdn.microsoft.com/fr-fr/library/windows/desktop/bb787524(v=vs.85).aspx

    这里写的清清楚楚,两个参数的作用:
    wParam : Handle to the device context for the static control window.
    lParam : Handle to the static control.

  • 相关阅读:
    Qt编译出错:“Cannot find file...... .pro."
    谈论如何有效地保护你的数据
    购书网
    VC非模态对话框创建和销毁
    在GUI程序中使用控制台的两种方法
    fatal error C1010: unexpected end of file while looking for precompiled header directive
    burp抓取手机包
    为firefox添加flash插件
    msfvenom生成linux后门
    kali下操作 Apache2
  • 原文地址:https://www.cnblogs.com/findumars/p/5218795.html
Copyright © 2011-2022 走看看