Taking Bitmap snapshot of a from or a control on a form

S

Sajjad

i have one application running remotly and want to take its window snapshort
at any given time,
Here is a code i wrote

public Bitmap GetPicture()

{

Bitmap sbmp = new Bitmap(1000, 1000);

Graphics g = Graphics.FromImage( sbmp );

System.Windows.Forms.PaintEventArgs pe = new PaintEventArgs(g, new
Rectangle(0, 0, 1000, 1000));

this.InvokePaint(this.picturebox, pe);

g.Dispose();

return sbmp;

}



problem with this code is that it works fine with picture box, but if i
specify this (current form) or any user control or IE webBrowser control i
dont get any thing back its just blank.

requirment is that it should be able to get snapshot even window is
minimized (or even hidden).

Thanks,

Sajjad
 
A

Atul Godbole

Try sending a WM_PRINT message to the control. If it supports the message,
it will print itself to the DC

Atul Godbole
http://www.ssware.com/
Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
 
S

Sajjad

do you have idea how can i do it from within .net
Atul Godbole said:
Try sending a WM_PRINT message to the control. If it supports the
message, it will print itself to the DC

Atul Godbole
http://www.ssware.com/
Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
 
A

Atul Godbole

Use the SendMessage method. You will need to do P/Invoke by using the
DLLImport attribute.

-Atul
http://www.ssware.com/
Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
 
J

Jeffrey Tan[MSFT]

Hi Sajjad,

Does my reply make sense to you? Is your problem resolved? Please feel free
to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top