Solved

How to redraw menu in a dialog

Posted on 2008-10-01
5
1,539 Views
Last Modified: 2013-11-20
Hi,
I have a dialog that contains a menu.
In a certain point I am disable all menu items and then, enable the menuitems back.
For some reason, the menu doesn't repaint and if I disable the menuitems, they don't look gray. Only after I will move the cursor on top the menuitems, they will redraw.

the following link was supposed to fix my problem but it doesn't :
http://support.microsoft.com/kb/242577


Attached, is a sample project that contains a menu in dialog with the code suggested by the link above.

 added a timer that change to menu enable status every 1 sec.
What I want is that the disable will look gray without the need to move the cursor on top the menu in order to make it redraw

I added .txt to all files so I can zip it and add it as attachment here.

Thanks,
Udi Raz
MenuInDialog.zip
0
Comment
Question by:UdiRaz
5 Comments
 
LVL 17

Expert Comment

by:CSecurity
Comment Utility
call UpdateWindow() function. may solve your problem...
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
Comment Utility
you might want to look into the function InvalidateRect,
basically this function tells a window it needs to redraw
http://msdn.microsoft.com/en-us/library/ms534893(VS.85).aspx
0
 

Author Comment

by:UdiRaz
Comment Utility
C Security : UpdateWindow() didn't help
Mark :
      CRect rect;
      GetWindowRect( rect );
      InvalidateRect( rect );

Didn't work either.

please check the sample project I attached
0
 
LVL 19

Accepted Solution

by:
alb66 earned 500 total points
Comment Utility
Try to call DrawMenuBar().
I cannot try your code since I have an older version of visual studio...
0
 

Author Closing Comment

by:UdiRaz
Comment Utility
Simple and beautiful. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

763 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

10 Experts available now in Live!

Get 1:1 Help Now