🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #3258

Re: NULL_BRUSH Problem

#3258
From: Bruce Wright
Date: Sat, 15 Jun 1991 19:12
47 lines
3082 bytes
In article <1991Jun14.205944.15227@cs.bham.ac.uk> nhj@cs.bham.ac.uk (Nick Jurascheck) writes:
>Has anyone had any experience of using NULL_BRUSH as a window background ? 
>
>i.e.  	wcClassName.hbrBackground = GetStockObject(NULL_BRUSH);
>	.
>	.
>	RegisterClass(&wcClassName);
>
>I've tried this and it seems to work... usually, but not in all cases.
>My program sometimes fails to redraw the background as transparent
>e.g. when you move any dialog box around, or when you cancel one
>particular dialog box. Any part of the box that was in the client area
>remains there.  Others work fine on OK or Cancel, unless you move them
>first!  Iconising and restoring the window clears the problem.

The documentation on NULL_BRUSH may not be very clear, but this is
in fact the proper behavior.  NULL_BRUSH is used when you aren't sure
what the background "ought" to be when the window is created - then
you can redraw the background when you get the WM_PAINT message, and
the background doesn't get redrawn twice.  This could be the case, for 
example, for a GIF viewer or some other kinds of graphics programs that 
might not want a solid or simple patterned background (the only options 
available if you use anything other than NULL_BRUSH for hbrBackground).
It might also be the case if the user could choose the background for
the window that differed from the Windows defaults.

In other words, NULL_BRUSH simply causes no action to be taken - and
in your case, if the obscured bitmap has not been saved and restored
when the dialog box exits, then the contents of the dialog box remain
on the screen and all of the newly unobscured windows receive a
WM_PAINT message.  Since the only thing displayed in your client area 
is your own background 8-), then your background is not repainted.

If I understand what you are trying to do - that is, that you want the
window to be transparent and be able to view the windows under your
client area - then this can't be done cleanly using the normal Windows 
procedures.  You could probably do it with a certain amount of trouble
by invalidating the windows obscured by your client area (walking the 
list of windows), or (probably a better approach) getting hold of the 
entire screen as a DC by using a CreateDC ("DISPLAY", NULL, NULL, NULL) 
call.  Look at the BLOWUP program given in Petzold's book "Programming 
Windows" for an example of the use of this to capture the screen.  You'd 
have to get to your toolbox through some normal window, of course ...

Good luck -

						Bruce C. Wright
Technical Details
Message-ID: <1991Jun15.191202.25819@rti.rti.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!emory!gatech!mcnc!rti!bcw
References: <1991Jun14.205944.15227@cs.bham.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!emory!gatech!mcnc!rti!bcw
From: bcw@rti.rti.org (Bruce Wright)
Newsgroups: comp.windows.ms.programmer
Subject: Re: NULL_BRUSH Problem
Summary: NULL_BRUSH works properly
Message-ID: <1991Jun15.191202.25819@rti.rti.org>
Date: 15 Jun 91 19:12:02 GMT
References: <1991Jun14.205944.15227@cs.bham.ac.uk>
Followup-To: comp.windows.ms.programmer
Organization: Research Triangle Institute, RTP, NC
Lines: 47