From wine-devel Sun Jun 17 15:41:02 2001 From: Malte.Starostik () t-online ! de (Malte Starostik) Date: Sun, 17 Jun 2001 15:41:02 +0000 To: wine-devel Subject: CS_PARENTDC problems X-MARC-Message: https://marc.info/?l=wine-devel&m=99279545811852 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: 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. This contradicts the API docu at http://msdn.microsoft.com/library/psdk/winui/winclass_3b1v.htm: 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. a little later, this is as near as the "classy" text comes to clipping: 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. 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.