I would like to take a "screen capture" of just a Form.
I've done the following:
internal void CaptureScreen()
{
Graphics g1 = CreateGraphics();
Image MyImage = new Bitmap(ClientRectangle.Width,
ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, ClientRectangle.Width,
ClientRectangle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);
MyImage.Save(@"Captured.jpg", ImageFormat.Jpeg);
}
[System.Runtime.InteropServices.DllImportAttribute( "gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
Int32 dwRop // raster operation code
);
Two questions:
1) CaptureScreen() works but in "Captured.jpg" I see my Form that is
not completely loaded (I see parts of my desktop behind some controls).
Is there a way to know if a Form is completely loaded/rendered ?
2) Then I will have to do this capture automatically and maybe without
showing the form to the user ; is it possible?
Thanks in advance 1 4611
jcmag,
If you use .NET 2.0 try using DrawToBitmap method of the control class.
It will take care of all this PInvokes that you have in your code.
In .NET 2.0 Form fires Shown event after the form is fully painted first
time.
--
HTH
Stoitcho Goutsev (100)
"jcmag" <jc***@yahoo.comwrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
>I would like to take a "screen capture" of just a Form.
I've done the following:
internal void CaptureScreen()
{
Graphics g1 = CreateGraphics();
Image MyImage = new Bitmap(ClientRectangle.Width,
ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, ClientRectangle.Width,
ClientRectangle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);
MyImage.Save(@"Captured.jpg", ImageFormat.Jpeg);
}
[System.Runtime.InteropServices.DllImportAttribute( "gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
Int32 dwRop // raster operation code
);
Two questions:
1) CaptureScreen() works but in "Captured.jpg" I see my Form that is
not completely loaded (I see parts of my desktop behind some controls).
Is there a way to know if a Form is completely loaded/rendered ?
2) Then I will have to do this capture automatically and maybe without
showing the form to the user ; is it possible?
Thanks in advance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stan Shankman |
last post by:
C# -- Visual Studio.Net – Windows Application
Greetings all,
How do I copy a Form’s image to a bitmap? – And do so before it gets to the screen.
I haven’t been able to find anyone that knows...
|
by: Per |
last post by:
Hi all,
This may be a newbie question, but I can't find the answer anywhere.
I want to make a capture of the screen, or a part of the screen, that
contains the main portion of the form.
Detecting...
|
by: TerryWilson |
last post by:
I am developing a web based service tool using asp.net that we will distribute with
our product. This service tool will be used for remotely configuring the product, problem
determination, etc. ...
|
by: kris_scheyer |
last post by:
Ok, here's what im trying to do:
I have a machine running XP embedded that has a webserver. I have a
button on the aspx web form that is supposed to capture the screen of
the computer hosting the...
|
by: Marcob |
last post by:
Is there any component out there to capture screen text from a specific
region on any active external application form.
Thanks
Marco
| |
by: Eddie Dunn |
last post by:
I have one here that I cannot find anything on in my searching.
I am implementing a screen capture functionality into my Visual Basic
..NET application.
The code I am using calls the bitblt...
|
by: Ian Ceicys |
last post by:
I’ve been tasked with doing documentation on the project I’ve recently
joined. Here’s what I’m looking for in terms of documentation. I want to
generate a diagram from a huge .net 1.1...
|
by: JP2006 |
last post by:
I'm trying to write a control that will take a screen capture of a
particular website when a user submits a form in a web application; one
of the form fields is for a URL - the control needs to get...
|
by: raylopez99 |
last post by:
Beware newbies: I spent a day before I figured this out: copying a
bitmap (image) file to file is not quite like copying a text file--you
have to do some tricks (see below), like using a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |