?
Solved

Get a partially covered window's canvas

Posted on 1998-07-25
6
Medium Priority
?
186 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:Levente
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Expert Comment

by:erajoj
ID: 1358676
It's not possible unless you put it on top. The window DC doesn't save any hidden information.
Set FormStyle := fsStayOnTop, take snapshot and reset FormStyle.

/// John
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1358677
Try Forrm.GetFormImage, it returns a bitmap that contains your form.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358678
Levente, did you try Matvey's suggestion? Form.GetFormImage...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Levente
ID: 1358679
Hi Matvey and Zifnab,

Yes, I've tried it and works perfectly. I think I should 've read the TForm help thoroughly. Sorry.

Levente
0
 
LVL 3

Accepted Solution

by:
Matvey earned 600 total points
ID: 1358680
OK, sorry for not asking permition, but I hope you'll agree that there is no need for this question to stay open anymore...
Glad to help, Matvey
0
 

Author Comment

by:Levente
ID: 1358681
Agreed. I was in a hurry and had no time to read the TForm help thorougly.

Levente
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question