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组框标题颜色变化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)