473,466 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I copy a Form's image to a bitmap? – And do so before it gets to the screen.

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 how to do this - - all I want to do is copy a Form’s image to a bitmap. - - In effect,
I want to take a window-shot of a Form, (as opposed to a “screen-shot”) but it must be done before that Form hits the screen.

Anyone? Ideas?

Thanks all,
-Stan Shankman
Nov 15 '05 #1
5 2357
You cannot. The form has to be drawn on the screen before you can capture
it's image.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Stan Shankman" <st********@visi.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
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 how to do this - - all I want to do is copy a Form's image to a bitmap. - - In effect, I want to take a window-shot of a Form, (as opposed to a "screen-shot") but it must be done before that Form hits the screen.
Anyone? Ideas?

Thanks all,
-Stan Shankman

Nov 15 '05 #2
> How do I copy a Form's image to a bitmap? - And do so before it gets to
the screen. - Stan You cannot. The form has to be drawn on the screen before you can capture
it's image.> - Bob


Thanks for the replay Bob, but let me ask you this: Would there be anyway to fake it that you know of? You know, some way to built a
"soft screen" - - a place in memory that I can "trick" the system into thinking is the real screen - - that sort of thing.
- Stan Shankman
Nov 15 '05 #3
Stan,

Maybe you could run the program one time and let the controls draw with the
default values that you desire and then alt-printscreen a screenshot of your
form. Then edit the bitmap to clip just the client area out of the
screenshot and save that as a resource in your project.

Then you will have access to the pseudo form before it's initial paint. That
is assuming that your form is always the same size and layout when it is
first displayed.

Something else to look into is maybe drawing the form on a back buffer. I'm
not sure if this can be done but I reason that if a control can be double
buffered then a form _may_ be coerced into drawing itself to an off-screen
hDC or Graphics object. I've not done this before but it would be worth
looking into.

Byron Cullen
ThunderTools

"Stan Shankman" <st********@visi.com> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
How do I copy a Form's image to a bitmap? - And do so before it gets to
the screen. - Stan
You cannot. The form has to be drawn on the screen before you can capture it's image.> - Bob


Thanks for the replay Bob, but let me ask you this: Would there be anyway

to fake it that you know of? You know, some way to built a "soft screen" - - a place in memory that I can "trick" the system into thinking is the real screen - - that sort of thing. - Stan Shankman

Nov 15 '05 #4
Byron,

Hey guy, thanks for the thoughts. The problem with letting the program draw the Form one time, is that it just won't work - because,
for one thing, the form keeps on changing. But also because allowing the form to make brief "appearances" before its "time" will be
cosmetically fouling to the overall screen presentation I'm trying to bring about.

Now on the other hand, that "back-buffer" idea of yours just might be a winner. The only problem is, I haven't a clue about how to
go about implementing such a scheme.

So, if anyone is monitoring this thread, and has anything to add, please feel free to jump in.

I know that MVP Bob Powell says it can't be done, -- and I'm not doubting his integrity on the matter. So excuse me if I hold out
faith that some down-and-dirty assembler trick or other can come along and get the job done. Sure, it may not be easy, but then
putting a million transistors on an integrated circuit and wiring them together weren't no simple trick either.

That's one small step for man . . .

- Stan Shankman

"Byron Cullen" <by******************@msn.com> wrote in message news:ug*************@tk2msftngp13.phx.gbl...
Stan,

Maybe you could run the program one time and let the controls draw with the
default values that you desire and then alt-printscreen a screenshot of your
form. Then edit the bitmap to clip just the client area out of the
screenshot and save that as a resource in your project.

Then you will have access to the pseudo form before it's initial paint. That
is assuming that your form is always the same size and layout when it is
first displayed.

Something else to look into is maybe drawing the form on a back buffer. I'm
not sure if this can be done but I reason that if a control can be double
buffered then a form _may_ be coerced into drawing itself to an off-screen
hDC or Graphics object. I've not done this before but it would be worth
looking into.

Byron Cullen
ThunderTools

"Stan Shankman" <st********@visi.com> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
How do I copy a Form's image to a bitmap? - And do so before it gets to
the screen. - Stan

You cannot. The form has to be drawn on the screen before you can capture it's image.> - Bob


Thanks for the replay Bob, but let me ask you this: Would there be anyway

to fake it that you know of? You know, some way to built a
"soft screen" - - a place in memory that I can "trick" the system into

thinking is the real screen - - that sort of thing.
- Stan Shankman

Nov 15 '05 #5
Stan,

Yeah Bob knows mystical things it seems :)

Going back to C++ days I remember you could use the CWindow::Print command
to have the window draw itself on the specified device context but I am too
new of a fish in the .NET waters to know where to start looking for
something similar. But maybe just saying that will spark an idea for
someone.

Here's another hack of an idea, but I'm not sure if it will work of course:

Set your window position somewhere entirely off screen and let the form draw
there (out of sight) then capture the Graphics object. Just a thought... I'm
a little fuzzy on the 'presentation' you are trying to accomplish so I may
be barking up the wrong dog again.

Byron Cullen
ThunderTools

"Stan Shankman" <st********@visi.com> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
Byron,

Hey guy, thanks for the thoughts. The problem with letting the program draw the Form one time, is that it just won't work - because, for one thing, the form keeps on changing. But also because allowing the form to make brief "appearances" before its "time" will be cosmetically fouling to the overall screen presentation I'm trying to bring about.
Now on the other hand, that "back-buffer" idea of yours just might be a winner. The only problem is, I haven't a clue about how to go about implementing such a scheme.

So, if anyone is monitoring this thread, and has anything to add, please feel free to jump in.
I know that MVP Bob Powell says it can't be done, -- and I'm not doubting his integrity on the matter. So excuse me if I hold out faith that some down-and-dirty assembler trick or other can come along and get the job done. Sure, it may not be easy, but then putting a million transistors on an integrated circuit and wiring them together weren't no simple trick either.
That's one small step for man . . .

- Stan Shankman

"Byron Cullen" <by******************@msn.com> wrote in message

news:ug*************@tk2msftngp13.phx.gbl...
Stan,

Maybe you could run the program one time and let the controls draw with the default values that you desire and then alt-printscreen a screenshot of your form. Then edit the bitmap to clip just the client area out of the
screenshot and save that as a resource in your project.

Then you will have access to the pseudo form before it's initial paint. That is assuming that your form is always the same size and layout when it is
first displayed.

Something else to look into is maybe drawing the form on a back buffer. I'm not sure if this can be done but I reason that if a control can be double buffered then a form _may_ be coerced into drawing itself to an off-screen hDC or Graphics object. I've not done this before but it would be worth
looking into.

Byron Cullen
ThunderTools

"Stan Shankman" <st********@visi.com> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
> How do I copy a Form's image to a bitmap? - And do so before it gets to > the screen. - Stan

> You cannot. The form has to be drawn on the screen before you can

capture
> it's image.> - Bob

Thanks for the replay Bob, but let me ask you this: Would there be
anyway to fake it that you know of? You know, some way to built a
"soft screen" - - a place in memory that I can "trick" the system into

thinking is the real screen - - that sort of thing.
- Stan Shankman


Nov 15 '05 #6

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

Similar topics

16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
0
by: Balu Ramachandran | last post by:
How can I create the Thumbnail view from the form? In the following approach I tried but Iams facing some limitations to get the thumbnail image of the form alone. Plaese any one can help in...
1
by: andrew | last post by:
I have a MSchart object (COM Component) which I wish to insert as an image into a picture box so that I can print it out. 'I call the chart controls's EditCopy to pass data to the clipboard. ...
40
by: Geoff Jones | last post by:
Hi Can anybody help me with the following? It is driving me crazy!!! I'm trying to produce a non-rectangular form as follows: (1) Produce a bitmap e.g. gif, using paint shop pro 5. (2) The...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
5
by: Minfu Lu | last post by:
Is there anybody knows how to copy a form (actually the image of a form) to clipboard? Jason
2
by: John | last post by:
The following 4 lines add a border to a bitmap and save it into clipboard, however it also add a border to the bitmap on the screen. I want to create a temp copy of the bitmap and add a border to...
1
by: icepick72 | last post by:
On an academic note, I want to copy a Graphic to an Image (Bitmap). I have the Graphic object but not the origin image from which it originates; this is because I'm overriding the PrintDocument...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.