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

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

MTB2440Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DanRollinsConnect With a Mentor Commented:
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
 
DanRollinsCommented:
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
 
MTB2440Author Commented:
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
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
DanRollinsCommented:
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
 
MTB2440Author Commented:
Why shouldn't CS_SAVEBITS be used on View Windows?

0
 
MTB2440Author Commented:
Does anyone know why CS_SAVEBITS should not be used in a View Window?
0
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
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
 
MTB2440Author Commented:
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
 
AndyAinscowFreelance programmer / ConsultantCommented:
>>>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
All Courses

From novice to tech pro — start learning today.