zoukankan      html  css  js  c++  java
  • TWinControl.WMNCPaint对非客户的绘制

    混个脸熟:

    procedure TWinControl.WMNCPaint(var Message: TMessage);
    const
      InnerStyles: array[TBevelCut] of Integer = (0, BDR_SUNKENINNER, BDR_RAISEDINNER, 0);
      OuterStyles: array[TBevelCut] of Integer = (0, BDR_SUNKENOUTER, BDR_RAISEDOUTER, 0);
      EdgeStyles: array[TBevelKind] of Integer = (0, 0, BF_SOFT, BF_FLAT);
      Ctl3DStyles: array[Boolean] of Integer = (BF_MONO, 0);
    var
      DC: HDC;
      RC, RW, SaveRW: TRect;
      EdgeSize: Integer;
      WinStyle: Longint;
    begin
      { Get window DC that is clipped to the non-client area }
      if (BevelKind <> bkNone) or (BorderWidth > 0) then
      begin
        DC := GetWindowDC(Handle);
        try
          Windows.GetClientRect(Handle, RC);
          GetWindowRect(Handle, RW);
          MapWindowPoints(0, Handle, RW, 2);
          OffsetRect(RC, -RW.Left, -RW.Top);
          ExcludeClipRect(DC, RC.Left, RC.Top, RC.Right, RC.Bottom);
          { Draw borders in non-client area }
          SaveRW := RW;
          InflateRect(RC, BorderWidth, BorderWidth);
          RW := RC;
          if BevelKind <> bkNone then
          begin
            EdgeSize := 0;
            if BevelInner <> bvNone then Inc(EdgeSize, BevelWidth);
            if BevelOuter <> bvNone then Inc(EdgeSize, BevelWidth);
            with RW do
            begin
              WinStyle := GetWindowLong(Handle, GWL_STYLE);
              if beLeft in BevelEdges then Dec(Left, EdgeSize);
              if beTop in BevelEdges then Dec(Top, EdgeSize);
              if beRight in BevelEdges then Inc(Right, EdgeSize);
              if (WinStyle and WS_VSCROLL) <> 0 then Inc(Right, GetSystemMetrics(SM_CYVSCROLL));
              if beBottom in BevelEdges then Inc(Bottom, EdgeSize);
              if (WinStyle and WS_HSCROLL) <> 0 then Inc(Bottom, GetSystemMetrics(SM_CXHSCROLL));
            end;
            DrawEdge(DC, RW, InnerStyles[BevelInner] or OuterStyles[BevelOuter],
              Byte(BevelEdges) or EdgeStyles[BevelKind] or Ctl3DStyles[Ctl3D] or BF_ADJUST);
          end;
          IntersectClipRect(DC, RW.Left, RW.Top, RW.Right, RW.Bottom);
          RW := SaveRW;
          { Erase parts not drawn }
          OffsetRect(RW, -RW.Left, -RW.Top);
          Windows.FillRect(DC, RW, Brush.Handle);
        finally
          ReleaseDC(Handle, DC);
        end;
      end;
    
      inherited; // 又发现这句对TWinControl.DefaultHandler的调用
    
      if ThemeServices.ThemesEnabled and (csNeedsBorderPaint in ControlStyle) then
        ThemeServices.PaintBorder(Self, False);
    end;
  • 相关阅读:
    字符编码
    visual studio 2015 安装记录和问题修复
    TCP状态转换图的理解
    静态库与动态库的编译链接
    运行库glibc
    堆栈的简单认识
    Makefile学习总结
    关于STM32单片机的IAP实现
    ubuntu12.0.4安装启动后无法进入图形操作界面
    观察者模式
  • 原文地址:https://www.cnblogs.com/findumars/p/5221873.html
Copyright © 2011-2022 走看看