Solved

Get a partially covered window's canvas

Posted on 1998-07-25
6
184 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 150 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2 89
Delphi Ado Query To Converts Joined Columns Into Rows Based on Primary Key 4 90
Delphi Seattle StructureView color 1 33
Firemonkey Listview item popup menu ? 1 71
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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