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

  • 相关阅读:
    POJ 2516 Minimum Cost [最小费用最大流]
    ZOJ 3407 Doraemon's Cake Machine [数学]
    ZOJ 2404 Going Home 【最小费用最大流】
    POJ 3422 Kaka's Matrix Travels 【最小费用最大流】
    树状数组的整理
    Day35 python基础--并发编程基础4
    Day34 python基础--并发编程基础3
    Day33 python基础--并发编程基础2
    Day32 python基础--并发编程基础1
    Day31 python基础--网络编程基础-socketserver
  • 原文地址:https://www.cnblogs.com/findumars/p/5218795.html
Copyright © 2020-2023  润新知