mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 15:40:41 +02:00
lcl: safer gdi handles typecasting
git-svn-id: trunk@15216 -
This commit is contained in:
parent
48abb9b26f
commit
e5b449c97e
@ -138,7 +138,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TBrush.SetHandle(const Value: HBRUSH);
|
||||
begin
|
||||
if FReference.Handle = Value then Exit;
|
||||
if HBRUSH(FReference.Handle) = Value then Exit;
|
||||
|
||||
FreeReference;
|
||||
FReference._lclHandle := TLCLHandle(Value);
|
||||
@ -154,7 +154,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TBrush.GetHandle: HBRUSH;
|
||||
begin
|
||||
Result := Reference.Handle;
|
||||
Result := HBRUSH(Reference.Handle);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -132,7 +132,7 @@ begin
|
||||
// ,' Brush=',DbgS(Brush));
|
||||
OldHandle := SelectObject(FHandle, HGDIOBJ(Brush.Reference.Handle));
|
||||
//debugln('TCanvas.CreateBrush ',ClassName,' Self=',DbgS(Self),' OldHandle=',DbgS(OldHandle),8),' NewHandle=',DbgS(Brush.Handle),' FSavedBrushHandle=',DbgS(Cardinal(FSavedBrushHandle));
|
||||
if (OldHandle <> Brush.Reference.Handle) and (FSavedBrushHandle=0) then
|
||||
if (OldHandle <> HBRUSH(Brush.Reference.Handle)) and (FSavedBrushHandle=0) then
|
||||
FSavedBrushHandle := OldHandle;
|
||||
Include(FState, csBrushValid);
|
||||
SetBkColor(FHandle, Brush.Color);
|
||||
@ -176,7 +176,7 @@ begin
|
||||
//DebugLn('[TCanvas.CreatePen] ',Classname,' Self=',DbgS(Self)
|
||||
// ,' Pen=',DbgS(Pen));
|
||||
OldHandle := SelectObject(FHandle, HGDIOBJ(Pen.Reference.Handle));
|
||||
if (OldHandle <> Pen.Reference.Handle) and (FSavedPenHandle=0) then
|
||||
if (OldHandle <> HPEN(Pen.Reference.Handle)) and (FSavedPenHandle=0) then
|
||||
FSavedPenHandle := OldHandle;
|
||||
MoveTo(PenPos.X, PenPos.Y);
|
||||
Include(FState, csPenValid);
|
||||
@ -198,7 +198,7 @@ begin
|
||||
// The TFont will call DeleteObject itself, so we never need to call it.
|
||||
OldHandle := SelectObject(FHandle, HGDIOBJ(Font.Reference.Handle));
|
||||
//DebugLn(['TCanvas.CreateFont OldHandle=',dbghex(OldHandle),' Font.Handle=',dbghex(Font.Handle)]);
|
||||
if (OldHandle <> Font.Reference.Handle) and (FSavedFontHandle=0) then
|
||||
if (OldHandle <> HFONT(Font.Reference.Handle)) and (FSavedFontHandle=0) then
|
||||
FSavedFontHandle := OldHandle;
|
||||
Include(FState, csFontValid);
|
||||
SetTextColor(FHandle, Font.Color);
|
||||
@ -212,7 +212,7 @@ var
|
||||
OldHandle: HRGN;
|
||||
begin
|
||||
OldHandle := SelectObject(FHandle, HGDIOBJ(Region.Reference.Handle));
|
||||
if (OldHandle <> Region.Reference.Handle) and (FSavedRegionHandle=0) then
|
||||
if (OldHandle <> HRGN(Region.Reference.Handle)) and (FSavedRegionHandle=0) then
|
||||
FSavedRegionHandle := OldHandle;
|
||||
Include(FState, csRegionValid);
|
||||
end;
|
||||
@ -850,7 +850,7 @@ procedure TCanvas.FillRect(const ARect : TRect);
|
||||
begin
|
||||
Changing;
|
||||
RequiredState([csHandleValid, csBrushValid]);
|
||||
LCLIntf.FillRect(FHandle, ARect, Brush.Reference.Handle);
|
||||
LCLIntf.FillRect(FHandle, ARect, HBRUSH(Brush.Reference.Handle));
|
||||
Changed;
|
||||
end;
|
||||
|
||||
@ -874,7 +874,7 @@ procedure TCanvas.FloodFill(X, Y: Integer; FillColor: TColor;
|
||||
begin
|
||||
Changing;
|
||||
RequiredState([csHandleValid, csBrushValid]);
|
||||
LCLIntf.FloodFill(FHandle, X, Y, FillColor, FillStyle, Brush.Reference.Handle);
|
||||
LCLIntf.FloodFill(FHandle, X, Y, FillColor, FillStyle, HBRUSH(Brush.Reference.Handle));
|
||||
Changed;
|
||||
end;
|
||||
|
||||
|
@ -1082,7 +1082,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TFont.GetHandle: HFONT;
|
||||
begin
|
||||
Result := Reference.Handle;
|
||||
Result := HFONT(Reference.Handle);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1112,7 +1112,7 @@ function TFont.GetCanUTF8: boolean;
|
||||
begin
|
||||
if not FCanUTF8Valid then
|
||||
begin
|
||||
FCanUTF8 := FontCanUTF8(Reference.Handle);
|
||||
FCanUTF8 := FontCanUTF8(HFONT(Reference.Handle));
|
||||
FCanUTF8Valid := True;
|
||||
end;
|
||||
Result := FCanUTF8;
|
||||
@ -1148,7 +1148,7 @@ function TFont.GetIsMonoSpace: boolean;
|
||||
begin
|
||||
if not FIsMonoSpaceValid then
|
||||
begin
|
||||
FIsMonoSpace := FontIsMonoSpace(Reference.Handle);
|
||||
FIsMonoSpace := FontIsMonoSpace(HFONT(Reference.Handle));
|
||||
FIsMonoSpaceValid := True;
|
||||
end;
|
||||
Result := FIsMonoSpace;
|
||||
@ -1169,7 +1169,7 @@ procedure TFont.SetData(const FontData: TFontData);
|
||||
var
|
||||
OldStyle: TFontStylesbase;
|
||||
begin
|
||||
if (FReference.Handle <> FontData.Handle) or not FReference.Allocated then
|
||||
if (HFONT(FReference.Handle) <> FontData.Handle) or not FReference.Allocated then
|
||||
begin
|
||||
OldStyle := FStyle;
|
||||
FreeReference;
|
||||
|
@ -158,7 +158,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TPen.SetHandle(const Value: HPEN);
|
||||
begin
|
||||
if FReference.Handle = Value then Exit;
|
||||
if HPEN(FReference.Handle) = Value then Exit;
|
||||
|
||||
FreeReference;
|
||||
FReference._lclHandle := TLCLHandle(Value);
|
||||
@ -174,7 +174,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TPen.GetHandle: HPEN;
|
||||
begin
|
||||
Result := Reference.Handle;
|
||||
Result := HPEN(Reference.Handle);
|
||||
end;
|
||||
|
||||
function TPen.GetReference: TWSPenReference;
|
||||
|
@ -72,7 +72,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TRegion.SetHandle(const Value: HRGN);
|
||||
begin
|
||||
if FRegionData.Reference.Handle = Value then Exit;
|
||||
if HRGN(FRegionData.Reference.Handle) = Value then Exit;
|
||||
|
||||
FreeReference;
|
||||
FRegionData.Reference._lclHandle := TLCLHandle(Value);
|
||||
@ -90,7 +90,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TRegion.GetHandle: HRGN;
|
||||
begin
|
||||
Result := Reference.Handle;
|
||||
Result := HRGN(Reference.Handle);
|
||||
end;
|
||||
|
||||
function TRegion.GetReference: TWSRegionReference;
|
||||
@ -177,7 +177,7 @@ function TRegion.GetClipRect : TRect;
|
||||
begin
|
||||
if FRegionData.Reference.Allocated
|
||||
then begin
|
||||
GetRgnBox(FRegionData.Reference.Handle, @Result)
|
||||
GetRgnBox(HRGN(FRegionData.Reference.Handle), @Result)
|
||||
end
|
||||
else begin
|
||||
if FRegionData.Polygon <> nil
|
||||
|
@ -4341,7 +4341,7 @@ var
|
||||
begin
|
||||
if DC = 0 then Exit;
|
||||
ARect := Rect(0, 0, Width, Height);
|
||||
FillRect(DC, ARect, Brush.Reference.Handle)
|
||||
FillRect(DC, ARect, HBRUSH(Brush.Reference.Handle));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user