How to determine Canvas dimensions by knowing only its Handle?
I would like to know width and height of canvas but I know only its HDC.
I've tried with this code:
procedure TForm92.Button1Click(Sender: TObject);
var
hBitmap: HGDIOBJ;
Header: TBitmapInfoHeader;
begin
hBitmap := GetCurrentObject(PaintBox1.Canvas.Handle, OBJ_BITMAP);
GetObject(hBitmap, sizeof(TBitmapInfoHeader), @Header);
ShowMessage(IntToStr(Header.biWidth));
end;
However it does not return me the dimensions of PaintBox1's Canvas,
instead I am getting the dimensions of the form on which the PaintBox1 is
placed.
What am I doing wrong?
No comments:
Post a Comment