fixed autosize of Checkbox

git-svn-id: trunk@7960 -
This commit is contained in:
vincents 2005-10-12 14:46:05 +00:00
parent b28e93cbd6
commit c67e75e666
2 changed files with 4 additions and 4 deletions

View File

@ -1071,7 +1071,7 @@ var
begin
winHandle := AWinControl.Handle;
canvasHandle := GetDC(winHandle);
oldFontHandle := SelectObject(canvasHandle, AWinControl.Font.Handle);
oldFontHandle := SelectObject(canvasHandle, Windows.SendMessage(winHandle, WM_GetFont, 0, 0));
Result := Windows.GetTextExtentPoint32(canvasHandle, PChar(Text), Length(Text), textSize);
if Result then
begin

View File

@ -1023,9 +1023,9 @@ var
begin
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
begin
// ~5 pixels spacing between checkbox and text, and 2 pixels margin for rounding error
Inc(PreferredWidth, GetSystemMetrics(SM_CXMENUCHECK) - GetSystemMetrics(SM_CXBORDER) + 7);
iconHeight := GetSystemMetrics(SM_CYMENUCHECK) - GetSystemMetrics(SM_CYBORDER);
// 7 pixels spacing between checkbox and text
Inc(PreferredWidth, GetSystemMetrics(SM_CXMENUCHECK) + 7);
iconHeight := GetSystemMetrics(SM_CYMENUCHECK);
if iconHeight > PreferredHeight then
PreferredHeight := iconHeight;
end;