WM_PRINT for themed controls
-
Hi, I'm trying to get a custom control to render its contents into a bitmap by sending it a WM_PRINT message. This works great if XP themes are not enabled. If XP themes are enabled, some controls (textbox, listview, listbox, treeview, datetimepicker) forget how to draw a themed border and draw an unthemed 3d border instead - and the groupbox only draws its background :wtf: Any ideas on how to get round this? "I think I speak on behalf of everyone here when I say huh?" - Buffy
-
Hi, I'm trying to get a custom control to render its contents into a bitmap by sending it a WM_PRINT message. This works great if XP themes are not enabled. If XP themes are enabled, some controls (textbox, listview, listbox, treeview, datetimepicker) forget how to draw a themed border and draw an unthemed 3d border instead - and the groupbox only draws its background :wtf: Any ideas on how to get round this? "I think I speak on behalf of everyone here when I say huh?" - Buffy
First, don't handle the
WM_PAINT
message. OverrideOnPaint
for your controls (unless you're using anIMessageFilter
or something) and useControl.SetStyle
with theControlStyles
enumeration (read the .NET Framework SDK documentation for details) to control exactly what gets drawn. If you don't want this code to run on Windows XP, use theEnvironment.Version
property to determine on what platform and version of the OS the environment (the CLR) is running. Use that as a condition to executing certain code.Microsoft MVP, Visual C# My Articles