473,396 Members | 1,907 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.

Screen shots

In a Delphi application I would use GetDC passing the handle of the window I
wanted to capture, then with the handle and a caption I would be able to
convert the image to a bitmap. I would like to be able to do this in
C#/.net, but I don't know where to start.

Can someone point me in the right direction?

Thanks
Wayne
Nov 16 '05 #1
2 1409
Wayne,

How you would do it in .NET isn't much different. You would have to
call the same API functions through the P/Invoke layer in order to do this,
as there is no way to get this out of the box.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wayne" <Me******@community.nospam> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
In a Delphi application I would use GetDC passing the handle of the window I wanted to capture, then with the handle and a caption I would be able to
convert the image to a bitmap. I would like to be able to do this in
C#/.net, but I don't know where to start.

Can someone point me in the right direction?

Thanks
Wayne

Nov 16 '05 #2
try this originally written by me, but modified by Jose Ines

[DllImport("user32.dll")]
extern static IntPtr GetDesktopWindow();

[System.Runtime.InteropServices.DllImport("user32.d ll")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);

[System.Runtime.InteropServices.DllImport("gdi32.dl l")]
private static extern UInt64 BitBlt
(IntPtr hDestDC,
int x,
int y,
int nWidth,
int nHeight,
IntPtr hSrcDC,
int xSrc,
int ySrc,
System.Int32 dwRop);

with the code of to do it here...

private Image Capture(){
Image myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
Graphics gr1 = Graphics.FromImage(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(GetDesktopWindow());
BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0, 13369376);
gr1.ReleaseHdc(dc1);

return myImage;

}

"Wayne" <Me******@community.nospam> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
In a Delphi application I would use GetDC passing the handle of the window I wanted to capture, then with the handle and a caption I would be able to
convert the image to a bitmap. I would like to be able to do this in
C#/.net, but I don't know where to start.

Can someone point me in the right direction?

Thanks
Wayne

Nov 16 '05 #3

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

Similar topics

0
by: Gianluca | last post by:
How can I store on file system the screen shot of my pc, automatically created each 30 minutes? I think it is necessary: 1) a component for managing print screen 2) a component for timing screen...
5
by: dave | last post by:
I want to include numerous screen prints about printing, date time settings, regional settings in the help files I will distribute with my application. Must I obtain written permission from...
0
by: topbooks | last post by:
I need find of which software is the best one you ever used that can capture screen shots and then let you add some comments, then combine them into a demo. The demo can be a set of web pages or...
8
by: gregory_may | last post by:
Is there a way to grab a "Screen Shot" that includes "Tool Tips"? I saw this code someplace, cant remember where. But it doesnt grab "Tool Tips". Is there a better way to do this in .net?...
0
by: Sinan Nalkaya | last post by:
hi i have some python practice and want to develop tiny prgramme that takes screen shots from command line, im using gnome now but my programme should support the others especially pure X - window....
0
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...
1
by: Daren Hawes | last post by:
Hi, I need some code that will create web site screen shots on the fly like this URL. http://search.ninemsn.com.au/previewx.aspx?q=www&FORM=CBPW&first=1&noredir=1 Any ideas where to start? ...
1
by: yatin | last post by:
i urgently want to know how can i take a screen shots of the video in the php, plz give me a suitable example or link. i am using a flb player on this i have to show the screen shots of videos.
4
mfshake
by: mfshake | last post by:
i need help on trying to print screen shots and put them on powerpoint with a timer. I tried to used the robot package and i couldn't get it to work. Can someone help me get started on this program....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...

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.