Render the WHOLE control

Started by
6 comments, last by pim 18 years, 10 months ago
Hi! Are there any ways to force a control to fully render itself even though it's hidden or partially covered (Win32 API or C#)? -Pim
Advertisement
Quote:Original post by pim
Are there any ways to force a control to fully render itself even though it's hidden or partially covered (Win32 API or C#)?

For MFC controls ::Invalidate() does the trick. For plain win32 API you might use ::InvalidateRect() with NULL as rectangle pointer.

(there's also ::RedrawWindow() which works in similar manner but allows more control over the whole thing...)
Are you sure this will repaint the control even if it's not visible or if it's partially covered? What I want to do, is render a hidden control to a custom device context so that I can save the whole image...
Hmm did a quick check and looks like no, the control is not guaranteed to get the WM_PAINT message if it's hidden (it does work for partially covered controls) You can give it explicit WM_PAINT call with ::SendMessage() though and this does get delivered.
But will it not be completely clipped since it's hidden?
Well, only one way to find out ;s

since you have access to DC --and consequently the control's clipping region-- in the paint routine for the control, you should be able to override it there if necessary... that's presuming a more straightforward approach like call to ::InvalidateRect() / ::InvalidateRgn() gets intercepted for hidden control.
if you need to circumvent windows regular drawing loop then you can always call paint directly just make sure to call begin paint endpaint, or use a CPaintDC to draw into. If you want an image then you can creatte a CPaintDC set a bmp into it, draw into the dc, then get a bmp out of it.

CHeers
Chris
CheersChris
Thanks for the replies... I don't have the code I was working on at hand for some time (I'm not at that computer), so I suppose I'll get back to it!

This topic is closed to new replies.

Advertisement