首页 > Windows开发 > 详细

TWinControl.DefaultHandler处理WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC消息的两个参数很有深意

时间:2016-02-26 00:15:53      阅读:433      评论:0      收藏:0      [点我收藏+]

 

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

TWinControl.DefaultHandler处理WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC消息的两个参数很有深意

原文:http://www.cnblogs.com/findumars/p/5218795.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!