DrawToBitmap problem

P

paulo

Hello,

I need to get an image from a control and all its children. I'm using
DrawToBitmap, but there are problems with the final result. There are
things that are not correctly painted on the image. I've tried other
approaches using the WM_PRINT message, but the result is the same.
Is there any way to get a perfect image? I can't use BitBlt or do a
screen capture because the control may be hidden from view.
Thanks in advance for any help given.

Regards,
paulo
 
P

paulo

Hello Stoitcho,

Not every children control is painted correctly. There are labels
missing, and even some entire controls.
I read somewhere that not every control responds correctly to the
WM_PRINT message, which is used by DrawToBitmap.
Is there an alternative to get the control image?

Regards,
paulo
 
S

Stoitcho Goutsev \(100\)

That is true. Good example is the RichTextBox; it doesn't support WM_PRINT
I'm not sure there is workaround.

However I was trying to help a person in this ng sometime ago with similar
problem. He didn't mind using PInvoke and I suggested using PrintWindow API
instead of sending WM_PRINT. MSDN says it is similar of using WM_PRINT, but
actually it sends WM_PAINT isntead and works in some places where WM_PRINT
doesn't.

PrintWindows did't help the other guy, but might help you.

The following is reference to our conversation back then
http://groups.google.ca/group/micro...public.dotnet.*&rnum=1&hl=en#67806bd349b07f61
 
P

paulo

Hello Stoitcho!

I want to thank you for your help.
PrintWindow is not perfect, but it sure is lots better than
DrawToBitmap. It works well 95% of the time!
Thank you so much for your help!

Regards,
paulo
 
J

Jeffrey Tan[MSFT]

Hi paulo,

Thanks for your post!

Normally, a control is a Window, and it paint itself in WM_PAINT message,
if a control does not provide support for WM_PRINT message, it means that
it does not provide any interface to get the painting behavior. It just
does the painting internally and does not want outside world to get its
painting behavior.

Regarding this scenario, we may have 2 choices:
1. Using BitBlt method to copy the surface manually
2. ControlPaint class exposes some drawing methods, which can be used to
draw some standard controls.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top