Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to snapshot canvas while off-screen

Posted on 2003-03-18
7
Medium Priority
?
479 Views
Last Modified: 2010-04-04
I need to snapshot the canvas of a form containing an active-x control... when it is placed off the screen.

To perform this for a form that is visible on screen I can use the following type of technique:
  FormDC := GetWindowDC( Aform.handle);
  BitBlt(bmp.Canvas.Handle, 0, 0, Width, Weight,
         FormDC, 0, 0, SRCCOPY);


Unfortunately, if I move the form to co-ordinates that are off screen (e.g. 5000,5000) the canvas copying just gives me a white image.

I have tried to understand if GetDCEx could be the answer, to get a DC that is not clipped by being off the screen. But I couldn't work it out.

Can anyone help?

Jonathan



0
Comment
Question by:jearle
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:rvicentiu
ID: 8162466
this should work:
(AForm.DoubleBuffered must be set to False)

var bmp:TBitmap;
begin
  bmp:=TBitmap.Create;
  Bmp.Height:=AForm.Height;
  Bmp.Width:=AForm.Width;
  AForm.PaintTo(Bmp.Canvas,0,0);
//...
  bmp.Free;
end;
0
 

Author Comment

by:jearle
ID: 8163053
That didn't work.
The PaintTo needs a Device Context. I tried:
  Aform.PaintTo( GetDC(Bmp.Canvas.Handle),0,0);
but just got a white bmp as the result.
0
 

Author Comment

by:jearle
ID: 8163161
In fact, the following is what is needed for paintto to be used:
  bmp.canvas.lock;
  PaintTo( Bmp.Canvas.Handle,0,0);
  bmp.canvas.unlock;

However, although this snapshots the form and any normal components, it just leaves a grey area where my active-x control is located.  So it is no better than GetFormImage.

Any other ideas ?


0
 
LVL 1

Accepted Solution

by:
rvicentiu earned 300 total points
ID: 8166093
Delphi 6 Forms have an overloaded version of PaintTo that works with a TCanvas parameter;
anyway the Bmp.Canvas.Handle is already a HDC not a HWnd, so calling GetDC won't work(Aform.PaintTo(GetDC(Bmp.Canvas.Handle),0,0);).
you can try sending a WM_PRINT/WM_PRINTCLIENT message(SendMessage(AForm.Handle, WM_PRINT, BMP.Canvas.Handle, PRF_CLIENT);) but Delphi forms don't seem to handle WM_PRINT
0
 

Expert Comment

by:CleanupPing
ID: 9316685
jearle:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

569 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