473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3113
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.fiw rote in message
news:11******** **************@ a39g2000hsc.goo glegroups.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
1852
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
4273
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 Graphics object, which is the same as if I'd need to print it. It'd be easy using Control.DrawToBitmap, but I also need the invisible part of the panel (which is hidden because of scrolling) and DrawToBitmap just takes a screenshot.
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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
9911
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
8934
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.