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.

  • 相关阅读:
    python
    UVA 10891——Game of Sum
    codeforces632E 小偷与商店
    NOIP2007——树网的核
    NOIP2014 提高组 Day2——寻找道路
    nodeoj2000——Freda's Chess
    BZOJ1012——[JSOI2008]最大数maxnumber
    poj2823-Sliding Window
    开博客了,大家好,这是ATHENS的博客。
    Linux简易APR内存池学习笔记(带源码和实例)
  • 原文地址:https://www.cnblogs.com/findumars/p/5218795.html
Copyright © 2011-2022 走看看