CS_PARENTDC problems

Malte Starostik Malte.Starostik at t-online.de
Sun Jun 17 10:41:02 CDT 2001


Hi,

we had some serious painting problems with dialog from an ActiveX control. 
All controls were invisible and only showed up sometimes on getting or losing 
focus. The cause is a custom class "_BitmapClass" that draws a logo and has 
the CS_PARENTDC class style (and no other class styles FWIW). Its 
WM_ERASEBKGND handler fills the complete dialog rect with that default 
Win95-Desktop-Background colour. According to the Win32 docs winelib behaves 
correctly wrt CS_PARENTDC and clipping. In this case it'd be Macromedia's 
fault as to how they implemented that window.
However, I just found 

http://msdn.microsoft.com/library/techart/msdn_classy32.htm:

<classy>
If you use the CS_PARENTDC style for a class, each window in that class uses 
its parent window's DC. CS_PARENTDC is similar to CS_CLASSDC in that multiple 
windows share one DC. In CS_PARENTDC, however, the windows that share the DC 
need not belong to the same class.
</classy>

This contradicts the API docu at 
http://msdn.microsoft.com/library/psdk/winui/winclass_3b1v.htm:

<api docs>
CS_PARENTDC
Sets the clipping rectangle of the child window to that of the parent window 
so that the child can draw on the parent. A window with the CS_PARENTDC style 
bit receives a regular device context from the system's cache of device 
contexts. It does not give the child the parent's device context or device 
context settings. Specifying CS_PARENTDC enhances an application's 
performance. 
<api docs>

a little later, this is as near as the "classy" text comes to clipping:

<classy>
Another outcome of the CS_PARENTDC style is that child windows can draw 
anywhere in their parent's client area as well as drawing in their own client 
area. The CTL3D library, which creates 3-D effects around edit controls and 
list boxes, relies on this behavior. An application should not use 
CS_PARENTDC if it needs to adjust the mapping modes for different child 
windows. This will negate much of the benefit and could cause problems 
ensuring that each child window has the correct mapping mode set.
</classy>

Then I tried on Windows (2000), created a window with a child that has 
CS_PARENTDC set and

* The paint rect of the PAINTSTRUCT as intialized by BeginPaint() equals the 
window's client rect - as expected.

* but - surprise - so does the DC's clip box and trying to largen it to cover 
some or all areas of the parent fail and of course any drawing on the parent 
fails.

* same for the DC returned by GetDC(hWnd)

* only GetDCEx(hWnd, 0, DCX_PARENTCLIP) returns a DC that allows painting on 
the parent (no difference to a non-CS_PARENTDC window though)

So, how is this painting on the parent with that style flag supposed to work? 
The things above make me think that it isn't possible at all or requires some 
additional steps.
This would at least explain why the dialog described above looks busted in 
wine. If anyone could confirm my observations I'd come up with a patch.
Thanks for any info,
-Malte
-- 
Wars don't determine who's right, only who's left.




More information about the wine-devel mailing list