Re: Minor Bug+Patch: Themed Groupbox captions incorrectly drawn
Thanks! I'll apply the patch into the next version.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
GetTextExtent32
instead of GetThemeTextExtent
.
--- E:\misc\winscp380source-orig\packages\my\XPThemes.pas Sat Oct 16 19:11:14 2004
+++ E:\misc\winscp380source\packages\my\XPThemes.pas Thu Mar 16 22:24:10 2006
@@ -31,6 +31,8 @@
FCloseThemeData: function(hTheme: THandle): HRESULT; stdcall;
FDrawThemeText: function(hTheme: THandle; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR; iCharCount: Integer;
dwTextFlags, dwTextFlags2: DWORD; const pRect: TRect): HRESULT; stdcall;
+ FGetThemeTextExtent: function(hTheme: THandle; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR; iCharCount: Integer;
+ dwTextFlags: DWORD; pBoundingRect: PRECT; var pExtentRect: TRect): HRESULT; stdcall;
FIsThemeBackgroundPartiallyTransparent: function(hTheme: THandle; iPartId, iStateId: Integer): BOOL; stdcall;
FDrawThemeParentBackground: function(hwnd: HWND; hdc: HDC; prc: PRECT): HRESULT; stdcall;
FGetThemeAppProperties: function: DWORD; stdcall;
@@ -78,6 +80,7 @@
FOpenThemeData := GetProcAddress(FThemeLib, 'OpenThemeData');
FCloseThemeData := GetProcAddress(FThemeLib, 'CloseThemeData');
FDrawThemeText := GetProcAddress(FThemeLib, 'DrawThemeText');
+ FGetThemeTextExtent := GetProcAddress(FThemeLib, 'GetThemeTextExtent');
FIsThemeBackgroundPartiallyTransparent := GetProcAddress(FThemeLib, 'IsThemeBackgroundPartiallyTransparent');
FDrawThemeParentBackground := GetProcAddress(FThemeLib, 'DrawThemeParentBackground');
FGetThemeAppProperties := GetProcAddress(FThemeLib, 'GetThemeAppProperties');
@@ -161,8 +164,9 @@
if Text <> '' then
begin
SetTextColor(DC, Graphics.ColorToRGB(Font.Color));
- GetTextExtentPoint32(DC, PChar(Text), Length(Text), Size);
- TextR := Rect(0, 0, Size.cx, Size.cy);
+ WText := Text;
+ XPTheme.FGetThemeTextExtent(GetButtonThemeData, DC, BP_GROUPBOX, StateID,
+ PWideChar(WText), Length(WText), DT_LEFT, nil, TextR);
if not UseRightToLeftAlignment then
OffsetRect(TextR, 8, 0)
else
@@ -185,7 +189,6 @@
SelectClipRgn(DC, 0);
if Text <> '' then
begin
- WText := Text;
XPTheme.FDrawThemeText(GetButtonThemeData, DC, BP_GROUPBOX, StateID,
PWideChar(WText), Length(WText), DT_LEFT, 0, TextR);
end;