?
Solved

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

Posted on 2009-04-11
10
Medium Priority
?
350 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
[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
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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 500 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 500 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
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…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

765 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