• 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.

  • 相关阅读:
    DPM(Deformable Part Model)原理详解(汇总)
    VS code配置docker的shell环境
    C++运算符重载规则
    typedef 和define的区别
    在ESP分区新建win10引导
    自动化学报投稿过程记录
    shell-grep命令详解(转)
    shell-sed命令详解(转)
    shell-命令行参数(转)
    sublimetext3-实用快捷键整理
  • 原文地址:https://www.cnblogs.com/findumars/p/5218795.html
Copyright © 2020-2023  润新知