473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Capture control as image when running in background

Hi

I've got a c# application that will often run in the background as it
is used to monitor connections to a host.

An activex control displays the communication between the app and the
host. When the host disconnects the app, I want to take a screen shot
of the active x control.

Two methods I've tried have worked, one using key commands to trigger a
print screen on the form, and another uses BitBlt to grab a specific
rectangle of the form. However both have the drawbacks that they do
not work properly when the application is not in the foreground. The
first method captures the active window, the second captures the right
area but whatever windows that are in front of the app will obscure it.

First method
example:http://www.cornetdesign.com/2005/04/...-using_08.html

Second method example:
http://groups.google.co.uk/group/mic...c5cc70953c86b2

Any ideas? I've had a look here:
http://msdn.microsoft.com/library/de...html/scibf.asp
but it looks very complicated.

Cheers
Al

Mar 3 '06 #1
3 6796
Hi Al,

As you are talking about an ActiveX control, I assume that it is an
unmanaged control.
You can expose a Public property of the control called pic which will return
a bitmap image
of the DC (If VC++ is used) or Image (If VB6 is used). Now, when a condition
occurs you read
the pic property & assign it to a picture. If you are using a .Net
component, you can grab e.graphics
of the component DC & return as a bitmap.

Hope this helps.
--
Radhakrishna Banavalikar
Vasant-Vihar, Thane, INDIA.
"al********@gmail.com" wrote:
Hi

I've got a c# application that will often run in the background as it
is used to monitor connections to a host.

An activex control displays the communication between the app and the
host. When the host disconnects the app, I want to take a screen shot
of the active x control.

Two methods I've tried have worked, one using key commands to trigger a
print screen on the form, and another uses BitBlt to grab a specific
rectangle of the form. However both have the drawbacks that they do
not work properly when the application is not in the foreground. The
first method captures the active window, the second captures the right
area but whatever windows that are in front of the app will obscure it.

First method
example:http://www.cornetdesign.com/2005/04/...-using_08.html

Second method example:
http://groups.google.co.uk/group/mic...c5cc70953c86b2

Any ideas? I've had a look here:
http://msdn.microsoft.com/library/de...html/scibf.asp
but it looks very complicated.

Cheers
Al

Mar 4 '06 #2
Thanks for the reply Radhakrishna.

The control doesn't seem to have a pic property. The closest thing to
what you're saying I have is the CreateGraphics method. I'm using C#
..NET.

Could you give an example please?

Does this method create the bitmap correctly regardless if the control
is in the foreground?

Thanks again

Aled

Mar 6 '06 #3
Just to update. I've used the following code to grab the screen which
works well.
Graphics g = this.CreateGraphics();
Size s = this.Size;
Image myImg = new Bitmap(s.Width, s.Height, g);
Graphics g2 = Graphics.FromImage(myImg);

IntPtr dc1 = g.GetHdc();
IntPtr dc2 = g2.GetHdc();

BitBlt(dc2, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height, dc1, 0, 0, SRCCOPY);
g.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);

myImg.Save(aFilename +
".jpg",System.Drawing.Imaging.ImageFormat.Jpeg );

However, it still doesn't get round the background procress problem.
If any window is in front of it, it grabs an app sized grab of that
instead.

Mar 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nou Dadoun | last post by:
I'm currently developing an application in C++/MFC (Visual Studio 6, if that makes a difference) and I'd like to avoid the Windows style UI widgets and dialogs if at all possible. In fact, what...
5
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. ...
3
by: senfo | last post by:
I developed a Windows control in VS 2005 that inherits from the PictureBox Control that adds the ability to select images in a Windows application. It is, however, experiencing a strange issue...
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...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
4
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
I know how to capture a keypress for a windows application, but how would I go about doing it for a windows service? Rather than having a form in focus all the time, I would prefer to have...
0
by: ikramalikhan | last post by:
i am developing a software in vb 6.0 as front end and msaccess as back end..i want to capture an ultrasound image via my vb form image control.my doctor client will capture live ultrasound image and...
1
by: gnewsgroup | last post by:
I have a user control called Footer.ascx, in which a background image is inserted like so: <div id="footerdiv" style="background-image:url('Images/ mybackground.jpg');...
0
by: JB | last post by:
On 8 Apr, 10:03, "DSK Chakravarthy" <dskch...@msn.comwrote: Thanks for the reply. So the first part is looking easy enough. As for the next part: Well I have a winform which has a few text...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.