Re: Default attributes in new Win32lib
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 19, 2004
- 459 views
R.Stowasser wrote: > > Hi Derek, > > thank you for the explanations why using WS_CLIPSIBLINGS as a default > style in Win32lib. They were very helpful for me and I have adapted my > code so that it will work now as expected. > There is one question which came up. Should repaintWindow() not have the > same effect in this case as the w32HPaint event? Not really. The handler for w32HPaint is designed to be called during a Windows Paint operation. This means that it expects that a device context will be already established for the control AND that DC will already have clipping regions defined in it for the siblings. Windows does this automatically for the programmer just before sending a WM_PAINT message to the application. This means that any drawing that happens during the paint operation, will be clipped so it doesn't interfere with other controls. If you call the w32Handler directly (e.g. invokeHandler(...)) without first setting up the appropriate device context, any drawing you do in that handler may overwrite pixels already drawn by other controls - that is, they are not clipped. To set up the device context for this is not a trival exercise. It is more involved that just getting the default DC for the control. You need to add clipping regions to avoid drawing on any overlapping controls. The repaintWindow() routine just informs Windows that the control needs to be repainted, so Windows then constructs the right DC and sends a WM_PAINT message to the application. So in your example, don't call the event handler directly. Also you don't need the call to repaintWindow() as it is done automatically the first time the window is displayed. -- Derek Parnell Melbourne, Australia