Article View: borland.public.cppbuilder.nativeapi
Article #10671Re: Painting with Windows...
From: Ed Mulroy [TeamB]
Date: Wed, 07 Apr 2004 17:49
Date: Wed, 07 Apr 2004 17:49
86 lines
4981 bytes
4981 bytes
> Don't worry, Ed, I'm not a newbie, I always keep > win32.hlp at hand. ;-) Also keep this link at hand: http://msdn.microsoft.com/library/default.asp > I've processed the WM_ERASEBKGND message by > returning a non-zero value without success. If you do that then you are responsible for painting the background either when processing that message or when processing the WM_PAINT message. > What is the difference between BeginPaint/EndPaint and > GetDC/ReleaseDC in a WM_PAINT message handler ? BeginPaint does a GetDC and loads the PAINTSTRUCT with the information such as the value of the HDC it got, a flag showing if the background should be erased, the RECT for the update area (ps.rcPaint) to be painted, determines if the caret is in the update area, hiding it if it is and sets up some information internal to Windows. It is supposed to also erase the background of the update region but I have had mixed results when depending upon it to do that. I remember some documentation saying that it sets a clipping area of the update region but I've found no problems drawing in the client area even if outside the update region. EndPaint validates the ps.rcPaint area, restores the caret, releases the HDC and handles some Windows internals. GetDC and ReleaseDC merely get and release another HDC for the client area. By calling them from within a WM_PAINT message you risk failure because there are only a limited number of DC's available, especially under Win 95/98/ME. > In order to repaint the window, I've called InvalidateRect with > the 3rd parameter set to TRUE, meaning I want to erase the > background. Everything is erased except the static controls' > captions, this means that when I change the captions with > SetWindowText, the old caption is still behind the new one. Windows' docs say that a static control just returns non-zero in response to an erase background message which implies they handle all of it in response to the paint message. Check what styles the controls have. Are you subclassing or superclassing those controls? To work around the funky painting you might try sending the control a WM_ENABLE message after setting the text. . Ed > Mark Morrisson wrote in message > news:4073caac$1@newsgroups.borland.com... > Hi Ed, > Thanks alot for your reply. I hope you're doing right. > > Well, you said that the outline was part of the non-client > area. You're right, it's precisely the reason why I wondered > why the outline wasn't drawn when I handled WM_PAINT > (thru calls to BeginPaint/EndPaint). I do not handle the > WM_NCPAINT message. Ok, I will ask the question differently. > What is the difference between BeginPaint/EndPaint and > GetDC/ReleaseDC in a WM_PAINT message handler ? > > In order to repaint the window, I've called InvalidateRect with > the 3rd parameter set to TRUE, meaning I want to erase the > background. Everything is erased except the static controls' > captions, this means that when I change the captions with > SetWindowText, the old caption is still behind the new one. > > I've processed the WM_ERASEBKGND message by returning > a non-zero value without success. Anyway, I repeat that static > controls are the -only- components that pose a problem. All > other components of the group box (lines and rectangles) are > erased fine before they are drawn again. > > Once again, you're right, when you call SetWindowText, Windows > should clear the background by itself before showing the new text. > But in my application, Windows clearly doesn't ! I have to iconize > the window, then open it up again in order to see the labels > displayed right. Though, my program doesn't specifically handle > this situation, the WM_PAINT is just sent once again to my > application. I think it must be due to a bug of Windows. > > Don't worry, Ed, I'm not a newbie, I always keep win32.hlp at hand. ;-)
Technical Details
Message-ID:
<40743f39@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40730473$1@newsgroups.borland.com> <407314f2$1@newsgroups.borland.com> <4073caac$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,d9cf3e1d5e3d04cb X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-07 11:10:31 PST From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <40730473$1@newsgroups.borland.com> <407314f2$1@newsgroups.borland.com> <4073caac$1@newsgroups.borland.com> Subject: Re: Painting with Windows... Date: Wed, 7 Apr 2004 13:49:19 -0400 Lines: 88 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 24.74.175.102 Message-ID: <40743f39@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081360185 24.74.175.102 (7 Apr 2004 10:49:45 -0800) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail