Solved

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

Posted on 2009-04-11
10
341 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

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

0
 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 57
changeXy challenge 13 81
Problem to event 3 92
Problem to App 4 78
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!    …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

11 Experts available now in Live!

Get 1:1 Help Now