473,399 Members | 3,106 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,399 software developers and data experts.

Get the graphics of a hidden control


Hi,

I've found a way to copy the visible presentation of a control on to a
picturebox (using Graphics and GDI). But this works only if the
control is visible. How can I have the control hidden and still
retreive the graphics of the control (have the control draw itself for
me)? And what makes a child control hide itself when its parent is
hidden?

Br,
Tom

Aug 20 '07 #1
4 3081
How can I have the control hidden and still retreive the graphics of the control?
Move it off-screen, perhaps on a separate form?
And what makes a child control hide itself when its parent is hidden?
Because that is the normaly behavior... if you hide a panel, you
expect the contents of the panel to hide... so where would it paint?

Marc

Aug 20 '07 #2
Hi,

I do not think it can be done, using GDI you can only access the screen,
there is no way for you to get the visible representation of a hidden
control cause, well it's hidden and therefore it has no visible
representation

"tomko" <to************@saunalahti.fiwrote in message
news:11**********************@a39g2000hsc.googlegr oups.com...
>
Hi,

I've found a way to copy the visible presentation of a control on to a
picturebox (using Graphics and GDI). But this works only if the
control is visible. How can I have the control hidden and still
retreive the graphics of the control (have the control draw itself for
me)? And what makes a child control hide itself when its parent is
hidden?

Br,
Tom

Aug 20 '07 #3
I do not think it can be done, using GDI you can only access the screen,
there is no way for you to get the visible representation of a hidden
control cause, well it's hidden and therefore it has no visible
representation
Could it be possible to write a custom control that would parent
another one, and even if it was hidden, it wouldn't let its child
control know this?

How does a control know if its parent is hidden, disabled etc? Are
there some standard events?

Br,
Tom

Aug 20 '07 #4
tomko wrote:
I've found a way to copy the visible presentation of a control on to a
picturebox (using Graphics and GDI). But this works only if the
control is visible. How can I have the control hidden and still
retreive the graphics of the control (have the control draw itself for
me)? And what makes a child control hide itself when its parent is
hidden?
It probably depends on the control.

For a control that is entirely managed code, the first thing I'd try is
the DrawToBitmap() method. But it's possible that if you really want to
do this, you might have to subclass the control, create your own Bitmap
for it to draw into, get a Graphics instance from the Bitmap, and then
call OnPaint with a PaintEventArgs with the Graphics property set to
your Graphics instance.

For a control that is substantially unmanaged code (ie, pretty much any
of the built-in controls), it's likely a lot more difficult or
impossible. If it's possible at all, you probably will have to use the
WM_PRINTCLIENT window message, sending it directly to the underlying
window handle for the control. You need to create the Bitmap and
Graphics as above, but then get the HDC from the Graphics and use that
as the wParam when sending the WM_PRINTCLIENT message.

This of course requires that the control actually handles the
WM_PRINTCLIENT message. According to MSDN all of the common controls
do, but you could run into exceptions anyway.

Trying to hack the normal to-screen drawing process of a control,
especially for controls that are essentially unmanaged, is likely to get
you nothing but headaches. :) Hopefully the above ideas give you
something more likely to work regardless of the on-screen state of the
control.

Pete
Aug 20 '07 #5

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

Similar topics

15
by: Hamed | last post by:
Have I posted the message to wrong newsgroup? Or Does the question is so much strage? Would someone please kindly direct me to a true newsgroup or resource? Best Regards Hamed
9
by: she_prog | last post by:
Dear All, I need to save the content of a panel to a bitmap. The panel can have many child controls which also need to be saved. The problem would be solved if I could have the panel saved to a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.