Levente
asked on
Get a partially covered window's canvas
Get a form's canvas ?
I need to save my form's entire canvas. Now I use the following code:
var AppDC : HDC;
Bitmap : TBitmap;
begin
Bitmap := TBitmap.Create;
Bitmap.Width := Form1.Width;
Bitmap.Height := Form1.Height;
AppDC := GetWindowDC( Form1.Handle );
BitBlt( Bitmap.Canvas.Handle, 0, 0, Width, Height, AppDC, 0, 0, SRCCOPY );
ReleaseDC( Form1.Handle, AppDC );
{ ... }
Bitmap.Free;
end;
This code works well, BUT when another window (such as System monitor)
partially covers my form this window's canvas is also saved to my Bitmap.
How can I save my forms canvas only even if it is partially covered ?
Any help is *greatly* appreciated.
Levente
I need to save my form's entire canvas. Now I use the following code:
var AppDC : HDC;
Bitmap : TBitmap;
begin
Bitmap := TBitmap.Create;
Bitmap.Width := Form1.Width;
Bitmap.Height := Form1.Height;
AppDC := GetWindowDC( Form1.Handle );
BitBlt( Bitmap.Canvas.Handle, 0, 0, Width, Height, AppDC, 0, 0, SRCCOPY );
ReleaseDC( Form1.Handle, AppDC );
{ ... }
Bitmap.Free;
end;
This code works well, BUT when another window (such as System monitor)
partially covers my form this window's canvas is also saved to my Bitmap.
How can I save my forms canvas only even if it is partially covered ?
Any help is *greatly* appreciated.
Levente
Try Forrm.GetFormImage, it returns a bitmap that contains your form.
Levente, did you try Matvey's suggestion? Form.GetFormImage...
ASKER
Hi Matvey and Zifnab,
Yes, I've tried it and works perfectly. I think I should 've read the TForm help thoroughly. Sorry.
Levente
Yes, I've tried it and works perfectly. I think I should 've read the TForm help thoroughly. Sorry.
Levente
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Agreed. I was in a hurry and had no time to read the TForm help thorougly.
Levente
Levente
Set FormStyle := fsStayOnTop, take snapshot and reset FormStyle.
/// John