By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
> 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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.