Help on Drawing in caption ....
stanleyh Stanley Man-Kit Ho Friday, July 26, 1996 Environment: VC++ 4.0, WIn95/NT Hi, I am trying to make the caption of my window with gradient fill (just like Office 95). I tried to override the following functions: CMainFrm::OnNcPaint CMainFrm::OnNcActivate CMainFrm::OnSysCommand I have already drawn sucessfully in the caption. My problem is: whenever I resize the window, the original caption color will be redrawn first, so it creates some flashing effect that I don't like. If I don't call the base class function, the flashing thing is gone, but the rest of the non-client area (scrollbar, toolbar. statusbar) will not be repainted. Any idea what I should do?? If I just move the window around without resizing, it works great. Thanks for any help. Stanley 8^) -- ______________________________________________________________________________ Stanley Man-Kit Ho Email: stanleyh@netcom.com Internet Commerce Division, Novell. mho@novell.com WWW: http://www.novell.com Running Windows 95/NT, OS/2 Warp ______________________________________________________________________________
Bradley A. Burns -- bburns@sprynet.com Wednesday, July 31, 1996 [Mini-digest: 5 responses] Stanley, What you will have to do to 1. Get rid of the flickering problem, and 2. Not have to draw every single aspect of the NC area is to Validate the parts of the NC area that YOU want to draw into. Try taking these steps when a OnNCPaint occurs: 1. Validate the area of the window's NC area that you are going to draw into; 2. Call the base class OnNCPaint function of the window whose NC area is to be painted. 3. Fill in the previously validated area with your own graphics. Bradley Burns bburns@sprynet.com Environment: VC++ 4.0, WIn95/NT ---------- > From: Stanley Man-Kit Ho> To: mfc-l@netcom.com > Subject: Help on Drawing in caption .... > Date: Friday, July 26, 1996 9:19 PM > > Environment: VC++ 4.0, WIn95/NT > > Hi, > > I am trying to make the caption of my window with gradient fill (just > like Office 95). I tried to override the following functions: > > CMainFrm::OnNcPaint > CMainFrm::OnNcActivate > CMainFrm::OnSysCommand > > I have already drawn sucessfully in the caption. My problem is: > whenever I resize the window, the original caption color will be redrawn > first, so it creates some flashing effect that I don't like. If I don't call > the base class function, the flashing thing is gone, but the rest of the > non-client area (scrollbar, toolbar. statusbar) will not be repainted. Any > idea what I should do?? If I just move the window around without resizing, it > works great. Thanks for any help. > > Stanley 8^) > -- > __________________________________________________________________________ ____ > > Stanley Man-Kit Ho Email: stanleyh@netcom.com > Internet Commerce Division, Novell. mho@novell.com > > WWW: http://www.novell.com Running Windows 95/NT, OS/2 Warp > __________________________________________________________________________ ____ -----From: "Rowan Trollope" Stanley, You can set the region that WM_NCPAINT uses when you call NCPAINT. That will prevent windows from painting the part of the caption that you paint, but not the rest of it. The following code works: { CRect rect; CRect excludeRect; // Initialize excludeRect to the area that you paint... GetWindowRect( rect ); CRgn rgn1, rgn2, rgn3; rgn1.CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ); rgn2.CreateRectRgn( excludeRect.left, excludeRect.top, excludeRect.right, excludeRect.bottom ); rgn3.CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ); rgn3.CombineRgn( &Rgn1, &Rgn2, RGN_DIFF ); DefWindowProc( WM_NCPAINT, (WPARAM)(HRGN)rgn3, 0 ); } - Rowan Trollope Dev Mgr, Symantec -----From: "Alistair Israel" (Some guesswork here...) Have you tried validating the caption area just before calling the base class' function/default window procedure? Hopefully this'll prevent the caption from being drawn then you can draw it yourself. Possible caveat: The window system menu icon and minimize/maximize/close buttons might *not* get drawn as well. In which case, you'd have to draw 'em yourself anyway. Alistair Israel (aisrael@hotmail.com) Developer Dude PilNet, Inc. http://202.47.133.168 [0800-2000 GMT+0800 only] --------------------------------------------------------- Get Your *Web-Based* Free Email at http://www.hotmail.com --------------------------------------------------------- -----From: Roger Onslow/Newcastle/Computer Systems Australia/AU Just guessing here.... Can you call your painting routine before the base class and use ValidateRect( LPCRECT lpRect ); to mark the area you have drawn as no longer dirty before you call the base class /|\ Roger Onslow ____|_|.\ ============ _/.........\Senior Software Engineer /CCC.SSS..A..\ /CC..SS...A.A..\ Computer /.CC...SS..AAA...\ Systems /\.CC....SSAA.AA../ Australia \ \.CCCSSS.AA.AA_/ \ \...........// Ph: +61 49 577155 \ \...._____// Fax: +61 49 675554 \ \__|_/\_// RogerO@compsys.com.au \/_/ \// -----From: Mark Conway I found similar problems if the window was created with the WS_CAPTION style. I found the itsybitsy sample on MSDN (written for Windows 3.1) a useful starting point - this turns these flags off at create time, and you have to override WM_NCCALCSIZE too. This means you're now responsible for drawing the buttons too, but at least Win95 includes functions to do this. hope this helps Mark.
| Вернуться в корень Архива |