473,769 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6829
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********@gma il.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.CreateGrap hics();
Size s = this.Size;
Image myImg = new Bitmap(s.Width, s.Height, g);
Graphics g2 = Graphics.FromIm age(myImg);

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

BitBlt(dc2, 0, 0, this.ClientRect angle.Width,
this.ClientRect angle.Height, dc1, 0, 0, SRCCOPY);
g.ReleaseHdc(dc 1);
g2.ReleaseHdc(d c2);

myImg.Save(aFil ename +
".jpg",System.D rawing.Imaging. ImageFormat.Jpe g);

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
2314
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 I'd really like to do is use HTML/web pages as the user interface and invoke my application in the background to do the heavy lifting. I'm fairly well experienced with web pages and I've written a fair amount of JavaScript at one time or another...
5
2383
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. One thing that I would like to be able to do is display a screen capture of our product running. I have the code to get the screen capture of the desktop and I also know how to send the image back to the client to be displayed. The problem is that...
3
2429
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 that I can't explain. One of the desired affects was to provide the ability to change the background color on images that were selected, as well as setting the background color back to its original color after the image had been deselected. To...
1
4507
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 an image of that web site so that it can be displayed later as a thumbnail image. I have code for taking a normal screen capture using GDI+ which works fine. What I am now trying to do is to modify it so the screen capture is of a remote...
6
7238
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 display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
4
13093
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 something running in the background. There are option such as having the form invisible (opacity set to zero) and settings it's location as -200, -200 so that it isn't on the screen, but this isn't the ideal solution.
0
1511
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 save it ti ms word file. my form should show a live telecast of ultrasound machine images while the patient is underging scanning.Then a operator will capture a perticular image,and press button capture.The still image should be saved in ms word...
1
2871
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'); background-position:center; background-repeat:no- repeat;" <!-- My footer content goes here. --</div> This Footer.ascx is under a folder called /UserControls (the leading forward slash indicates the root of the web application, same below).
0
1580
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 boxes and 1 image. The text boxes, well i suppose they are pretty standard. The font and size will always be the same if that would be an issue. The boxes will always be at the same position on the window, and the window always the same size.
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
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 we have to send another system

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.