[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Window taking over my WM_NCPAINT message!

Posted on 2002-07-19
4
Medium Priority
?
881 Views
Last Modified: 2011-08-18
Dear programming buddies!

      I have written a class that customizes the caption titlebar of my main application window. It stretchblt's  it of a series of tileable bitmaps. As a result, the close, minimize and restore buttons are also drawn of a small bitmap.

      The effect desired is a titlebar that appears more alive, one that responds to mouse movement where caption buttons light up when moving the cursor over them, as well as WM_LBUTTONDOWN bitmaps etc. That sort of thing.

I have handled WM_NCPAINT, and WM_NCACTIVATE in order to achieve this. But I have come accross a HUGE bug which I can't find to solve.

IN WINDOWS '98 THE FOLLOWING HAPPENS:

      After I have received a WM_CONTEXTMENU message, invoked by either mouse or keyboard events, the three buttons as well as the background bitmap around the region of the caption buttons disappear after clicking inside the caption titlebar.

       I have used Spy++ to take a look at my messages, and quite strangely Windows performs default processing by drawing your ordinary button type caption buttons as well as a part of the caption bar around the region of the caption buttons. It appears that Windows simply erases my bitmap with its own default button drawing mechanism.

      The reason why this puzzles me is the fact that I have not received a WM_NCPAINT message at all, meaning that there is no invalid region on the non-client area. I even tried calling my OnNcPaint() function in between the messages sent on button clicks and mouse movements and after receiving WM_CONTEXTMENU, but only to cause unwanted flickering.

      Windows can't be doing DefWindowProc() for drawing default buttons, as this would only happen after I have received WM_NCPAINT, and I am not calling DefWindowProc() in my WM_NCPAINT message handler. My OnNcPaint() message handler is fully responsible for drawing the caption titlebar as well as the window frame.

      When I move the window with the caption buttons out of the desktop boundaries, and move it back to a viewable spot, my bitmap buttons reappear, only to disappear mysteriously after you click on the titlebar, or quite so often after a mousemove/hittest message.

IN WINDOWS 2000, SOMETHING SIMILAR HAPPENS:

      The whole insident as mentioned above happens with only one difference, Windows only takes over after I have minimized the application by clicking on the taskbar button, WM_CONTEXTMENU has no effect. When I click the minimize button beforehand, it does not affect the application in this way either, only clicking the taskbar causes Windows to take over. After "taskbar minimizing" Windows starts redrawing my caption buttons and the background region around them, thus erasing my blt'ed bitmap. Drawing is done, and WM_NCPAINT is not even in sight in Spy++ (and I am filtering out ALL messages, if you were wondering) !!!

      Please note: This all happens in Win32 API code, I'm not using MFC at all.

      Please, please, please take a look at this and help me find a solution. If you would like to have the source code, email me at josamoto@hotmail.com.

MY PRESUMPTION IS AS FOLLOWS:

      I thought that somewhere along the line, I lost a DC or forgot to restore to the previously selected HGDIOBJ. This was not the matter however, I made dead sure that all my device contexts are restored and my GDI objects are deleted from memory after I have used them and unselected them from their DC's. I think I'm just not catching the right message somewhere along the line, or Windows sets a flag which I know not where to find to reset.

! ! ! PLEEZ HELP ME, I'M HOPELESSLY NOT SURE WHAT TO DO ANYMORE, AND I AM NOT GIVING UP ! ! !
0
Comment
Question by:josamoto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 1340 total points
ID: 7212141
I believe this issue (or at least a set of similar problems relating to custom NC painting) is covered in this article:

   http://search.microsoft.com/gomsuri.asp?n=1&c=rp_Results&siteid=us/dev&target=http://www.microsoft.com/MSJ/0197/c++/C++0197.htm

Don't be put off by the mention of MFC.  The painting and flicker-elimination issues are the same with MFC or straight Win32.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7212143
I just tried that link and it seems to be broken.  You can find the Paul Dilascia article in MSDN by searching for this phrase:
    "The instant your poor title bar"
(including the quote marks).
-- Dan
0
 
LVL 11

Expert Comment

by:griessh
ID: 7378261
Dear josamoto

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "DanROllins"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7419935
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question