Solved

How do I stop the Menu from invalidating the region under the dropdown submenu?

Posted on 2009-04-11
10
337 Views
Last Modified: 2013-11-20
I'm using an MFC Doc/View structure. When the menu drops down over the draw screen (CView window), the region under the menu area is invalidated and a WM_PAINT message is issued.

CMenu::TrackPopupMenu also invalidates the region. I thought Windows managed an offscreen bitmap to automatically handle this.

I use CS_SAVEBITS , but that doesn't seem to help. Perhaps I do not have the right combination of flags.

Can you help?

Thanks,
Matt
cs.lpszClass = AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_SAVEBITS, AfxGetApp()->LoadCursor(IDC_NULL_CURSOR), (HBRUSH) (COLOR_WINDOW +1));

Open in new window

0
Comment
Question by:MTB2440
  • 4
  • 3
  • 2
10 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 24124449
Why do you care?
The underlying window should be able to redraw its invalidated region in a blink of an eye (say, a few milliseconds) How can you even perceive that there is a problem?
0
 

Author Comment

by:MTB2440
ID: 24124556
I work with large CAD drawings can take several seconds to draw. It's not uncommon to have 200,000  geometry objects in the drawing database.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 24125502
OK.
CS_SAVEBITS is normally used on windows that popup over other windows.  It causes the popup (such as a menu) to save the image that it obscures.  You should not use it on your view window.
 
    About Window Classes
    http://msdn.microsoft.com/en-us/library/ms633574(VS.85).aspx#class_styles  

Using Spy++ on the view window reveals that when a menu drops down, or rolls back up, there are no messages at all sent to the view.  Try this with a test-case SDI app, such as a one with a CEditView view.
I'm having to guess that there is something in your own code that is triggering the invalidation and redrawing messages.
0
 

Author Comment

by:MTB2440
ID: 24125665
Why shouldn't CS_SAVEBITS be used on View Windows?

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:MTB2440
ID: 24130824
Does anyone know why CS_SAVEBITS should not be used in a View Window?
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 125 total points
ID: 24132681
For the reason that I stated, and as described in the article I linked.
CS_SAVEBITS should be used for small, short-term popup windows so that they can automatically restore the portion of the screen that they obscured when they popped up.
For instance, if a window has the CS_SAVEBITS setting, then before it gets drawn, it saves the portion of the screen that it will be covering. Then, when it disappears, it repaints that portion of the screen that it covered -- without going through the normal process of requesting the underlying window to redraw itself.  You have gotten the meaning reversed, thinking that the setting should be used on the underlying window.
I'm not saying that this is the cause of the problem that you are experiencing, or that removing it is actually necessary... I AM saying that setting this bit cannot solve that problem.
If you show some other code, such as where you set the view window's styles and extended styles, then I mght be more able to focus on theis specific problem. For instance, does the view window end up hosting an ActiveX control? If so, show the code.
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 125 total points
ID: 24136039
WM_INITMENUPOPUP Notification  
The WM_INITMENUPOPUP message is sent when a drop-down menu or submenu  is about to become active. This allows an application to modify the menu before  it is displayed, without changing the entire menu.


You should be able to trap that message, make a copy of the window's DC into a bitmap and restore it when the menu is destroyed.
0
 

Author Comment

by:MTB2440
ID: 24148341
Thank you for the ideas and information. I need to create a same app and compare it to the full app and see what is causing the Repaint messages. The odd thing is Repaint messages are not issued for the first 3 menu dropdowns (File/Edit/Draw). There are a lot of clues, just need to explore some more.

Andy - I used INITMENUPOPUP for setting the checkmarks, etc. Is there a notification code for when the dropdown goes away; simlar to CBN_CLOSEUP?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 24149138
>>>Is there a notification code for when the dropdown goes away; simlar to CBN_CLOSEUP?

Offhand I don't know, I'll have to have a quick look.  (At the very least you could use the WM_PAINT and check if you made a screen dump to bitmap)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now