Solved

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

Posted on 2009-04-11
10
339 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

920 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

15 Experts available now in Live!

Get 1:1 Help Now