?
Solved

how to snapshot canvas while off-screen

Posted on 2003-03-18
7
Medium Priority
?
449 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
[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
  • 2
  • 2
7 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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

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