delphi组框标题颜色变化

delphi组框标题颜色变化,第1张

概述我正在使用BDS 2006,并想知道你是否可以使用项目中存在的XPmanifest更改Group-box和radio组标题颜色(因为它总是蓝色). 唯一的方法是覆盖 TGroupBox的Paint方法. 检查此示例使用Interposer类 type TGroupBox = class(StdCtrls.TGroupBox) //declare this before of your for 我正在使用BDS 2006,并想知道你是否可以使用项目中存在的XPmanifest更改Group-Box和radio组标题的颜色(因为它总是蓝色).解决方法 唯一的方法是覆盖 TGroupBox的Paint方法.

检查此示例使用Interposer类

type  TGroupBox = class(StdCtrls.TGroupBox) //declare this before of your form deFinition  public    procedure Paint; overrIDe;  end;uses themes;{ TGroupBox }procedure TGroupBox.Paint;var  H: Integer;  R: TRect;  Flags: Longint;  CaptionRect,OuterRect: TRect;  Size: TSize;  Box: Tthemedbutton;  Details: TthemedElementDetails;begin  with Canvas do  begin    Font := Self.Font;    if themeControl(Self) then    begin      if Text <> '' then      begin        GetTextExtentPoint32(Handle,PChar(Text),Length(Text),Size);        CaptionRect := Rect(0,Size.cx,Size.cy);        if not UseRightToleftAlignment then          OffsetRect(CaptionRect,8,0)        else          OffsetRect(CaptionRect,WIDth - 8 - CaptionRect.Right,0);      end      else        CaptionRect := Rect(0,0);      OuterRect := ClIEntRect;      OuterRect.top := (CaptionRect.Bottom - CaptionRect.top) div 2;      with CaptionRect do        ExcludeClipRect(Handle,left,top,Right,Bottom);      if Enabled then        Box := tbGroupBoxnormal      else        Box := tbGroupBoxDisabled;      Details := themeServices.GetElementDetails(Box);      //Draw the themed frame      themeServices.DrawElement(Handle,Details,OuterRect);          SelectClipRgn(Handle,0);      if Text <> '' then      begin         H := TextHeight('0');         if not UseRightToleftAlignment then           R := Rect(8,H)         else           R := Rect(R.Right - Canvas.TextWIDth(Text) - 8,H);         Flags := DrawTextBIDiModeFlags(DT_SINGLEliNE);         //Now using the windows.DrawText          DrawText(Handle,R,Flags or DT_CALCRECT);         Brush.color := color;//background color of the caption         Font.color := clRed;//the color of the caption.         DrawText(Handle,Flags);      end;    end    else    inherited;   //if the control is not themed then use the original paint method.  end;end;
总结

以上是内存溢出为你收集整理的delphi组框标题颜色变化全部内容,希望文章能够帮你解决delphi组框标题颜色变化所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1251457.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存