diff --git a/lcl/grids.pas b/lcl/grids.pas index 770b8fe7c0..c04e346db4 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -8198,9 +8198,8 @@ end; procedure TGridColumnTitle.SetFont(const AValue: TFont); begin - if AValue.Handle<>FFont.Handle then begin + if not FFont.IsEqual(AValue) then FFont.Assign(AValue); - end; end; procedure TGridColumnTitle.SetLayout(const AValue: TTextLayout); @@ -8467,9 +8466,8 @@ end; procedure TGridColumn.SetFont(const AValue: TFont); begin - if AValue.Handle<>FFont.Handle then begin + if not FFont.IsEqual(AValue) then FFont.Assign(AValue); - end; end; procedure TGridColumn.SetLayout(const AValue: TTextLayout); diff --git a/lcl/include/customlabel.inc b/lcl/include/customlabel.inc index ad4fd47d03..82140103b8 100644 --- a/lcl/include/customlabel.inc +++ b/lcl/include/customlabel.inc @@ -36,19 +36,19 @@ var OldFont: HGDIOBJ; LabelText: string; begin - if (Parent=nil) or (not Parent.HandleAllocated) then exit; + if (Parent=nil) or (not Parent.HandleAllocated) then Exit; DC := GetDC(Parent.Handle); try - R := Rect(0,0, Width, Height); - OldFont:=SelectObject(DC, Font.Handle); - Flags:=DT_CalcRect; + R := Rect(0, 0, Width, Height); + OldFont := SelectObject(DC, Font.Reference.Handle); + Flags := DT_CalcRect; if WordWrap then inc(Flags, DT_WordBreak) else if not HasMultiLine then inc(Flags, DT_SingleLine); - LabelText:=GetLabelText; + LabelText := GetLabelText; DrawText(DC, PChar(LabelText), Length(LabelText), R, Flags); SelectObject(DC, OldFont); // add one to be able to display disabled label @@ -338,7 +338,7 @@ begin and (CurFontHeight<=MaxFontHeight) do begin AFont.Height:=CurFontHeight; // NOTE: some TFont do not allow any integer //debugln('TCustomLabel.CalcFittingFontHeight A ',dbgs(MinFontHeight),'<=',dbgs(AFont.Height),'<=',dbgs(MaxFontHeight)); - OldFont:=SelectObject(DC, AFont.Handle); + OldFont := SelectObject(DC, AFont.Reference.Handle); DrawText(DC, PChar(TheText), Length(TheText), R, Flags); SelectObject(DC, OldFont); NeededWidth := R.Right - R.Left; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 0246e7f6a8..c11d669e31 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -4343,9 +4343,9 @@ procedure TWinControl.EraseBackground(DC: HDC); var ARect: TRect; begin - if DC=0 then exit; - ARect:=Rect(0,0,Width,Height); - FillRect(DC,ARect,Brush.Handle) + if DC = 0 then Exit; + ARect := Rect(0, 0, Width, Height); + FillRect(DC, ARect, Brush.Reference.Handle) end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/win32/win32wsbuttons.pp b/lcl/interfaces/win32/win32wsbuttons.pp index bdb456546e..5ff78431e1 100644 --- a/lcl/interfaces/win32/win32wsbuttons.pp +++ b/lcl/interfaces/win32/win32wsbuttons.pp @@ -165,7 +165,7 @@ var // fill with background color OldBitmapHandle := SelectObject(hdcNewBitmap, NewBitmap); - Windows.FillRect(hdcNewBitmap, BitmapRect, BitBtn.Brush.Handle); + Windows.FillRect(hdcNewBitmap, BitmapRect, BitBtn.Brush.Reference.Handle); if AState <> bsDisabled then begin if (srcWidth <> 0) and (srcHeight <> 0) then @@ -237,7 +237,7 @@ begin BitBtnLayout := BitBtn.Layout; BitBtnDC := GetDC(BitBtnHandle); hdcNewBitmap := CreateCompatibleDC(BitBtnDC); - OldFontHandle := SelectObject(hdcNewBitmap, BitBtn.Font.Handle); + OldFontHandle := SelectObject(hdcNewBitmap, BitBtn.Font.Reference.Handle); {$IFDEF WindowsUnicodeSupport} if UnicodeEnabledOS then begin diff --git a/lcl/interfaces/win32/win32wscontrols.pp b/lcl/interfaces/win32/win32wscontrols.pp index 03a1513f43..d252e3f4c1 100644 --- a/lcl/interfaces/win32/win32wscontrols.pp +++ b/lcl/interfaces/win32/win32wscontrols.pp @@ -259,7 +259,7 @@ begin if AWinControl.Font.IsDefault then lhFont := GetStockObject(DEFAULT_GUI_FONT) else - lhFont := AWinControl.Font.Handle; + lhFont := AWinControl.Font.Reference.Handle; Windows.SendMessage(Window, WM_SETFONT, WPARAM(lhFont), 0) end; end; @@ -280,7 +280,7 @@ begin if AWinControl.Font.IsDefault then lhFont := GetStockObject(DEFAULT_GUI_FONT) else - lhFont := AWinControl.Font.Handle; + lhFont := AWinControl.Font.Reference.Handle; Windows.SendMessage(Buddy, WM_SETFONT, lhFont, 0); end else @@ -467,7 +467,7 @@ class procedure TWin32WSWinControl.SetFont(const AWinControl: TWinControl; const begin if not WSCheckHandleAllocated(AWinControl, 'SetFont') then Exit; - Windows.SendMessage(AWinControl.Handle, WM_SETFONT, Windows.WParam(AFont.Handle), 1); + Windows.SendMessage(AWinControl.Handle, WM_SETFONT, Windows.WParam(AFont.Reference.Handle), 1); end; class procedure TWin32WSWinControl.SetText(const AWinControl: TWinControl; const AText: string); diff --git a/lcl/widgetset/wsreferences.pp b/lcl/widgetset/wsreferences.pp index 96daec9afd..d804d2bd10 100644 --- a/lcl/widgetset/wsreferences.pp +++ b/lcl/widgetset/wsreferences.pp @@ -80,7 +80,7 @@ type TWSBitmapReference = object(TWSGDIObjReference) property Handle: THandle read FRef.Handle; end; - + TWSBrushReference = object(TWSGDIObjReference) property _lclHandle: THandle write FRef.Handle; property Handle: THandle read FRef.Handle; @@ -105,7 +105,9 @@ type property Handle: THandle read FRef.Handle; end; - + TWSIconReference = object(TWSReference) + property Handle: THandle read FRef.Handle; + end; implementation