I use this code in my project:
var
P: TPoint;
MyControl.Perform(WM_LBUTTONDOWN, 0, Longint(PointToSmallPoint(P)));
The compiler gives me a warning:
[Warning]: Unsafe typecast of 'TSmallPoint' to 'Integer'
But, the same code is used in Controls.pas
without any warnings - for example in TControl.BeginDrag
method:
....
Perform(WM_LBUTTONUP, 0, Longint(PointToSmallPoint(P)));
I don't see any {$warnings off}
in Controls.pas
unit.
Why is the compiler warning me, but skips the warning for Controls.pas
?
Is this code Unsafe?
Edit: in my Project Options -> Compiler Messages -> Unsafe Typecast is checked (which by default is unchecked).
Maybe this is why @David and @Ken could not reproduce the warning.
procedure TForm3.FormCreate(Sender: TObject); var P: TPoint; begin P := Mouse.CursorPos; Perform(WM_LBUTTONDOWN, 0, Longint(PointToSmallPoint(P))); end;
– Braggunsafe type cast
unchecked, because it's no longer applicable. (It was added in Delphi 6 or 7 for .net compatibility when they were developing Delphi for .NET, to make it easier to write code that worked for both .NET and Win32; since the Delphi for .NET product was discontinued, that warning (and the two above it) are not applicable any longer). – Bragg