Solved

Menu Item

Posted on 2001-09-14
4
255 Views
Last Modified: 2010-04-02
I was interested on interacting between a variable and menu item using the check mark in the menu item such as the one by the Status Bar Item under View menu item in the windows explorer.

I like to know if the item is checked or not via some variable.

Thanks
Matt
0
Comment
Question by:mrfard
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Axter
Comment Utility
What type of project do you have?
What is the compiler?
What is the target OS?
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
Comment Utility
If you are writing in MFC, the easist way is to use the ON_UPDATE_COMMAND_UI handler.  When you want a checkmark to appear, use (eg)

void CMainFrame::OnUpdateViewStatusBar(CCmdUI* pCmdUI)
{
    pCmdUI->SetCheck( m_fShowStatusBar );
}

where m_fShowStatusBar is a member variable (BOOL) that reflects the show.hide state of the status bar.  

If you are programming in non-MFC for Windows, it is a bit more complicated because you need to get a handle to a submenu, but it boils down to using the CheckMenuItem() Win32 API fn.

If you are programming in Unix, u r on ur own.

-- Dan
0
 

Author Comment

by:mrfard
Comment Utility
Sorry;

I am writing it in Visual C++ (MFC), for windows 2000.

To DanRolling:

I might have misled you, I am not working with the status bar, I was just using it as a example. I actually want to check or uncheck an item in the menu bar and by doing that change a Boolean variable. The same as in windows explorer you can make the status bar appear or disappears by checking or uncheck the menu item under View menu.

Thanks
Matt
0
 

Author Comment

by:mrfard
Comment Utility
Dan;

I read your solution aging and it is exactly what I need.

Thanks
Matt
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

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

7 Experts available now in Live!

Get 1:1 Help Now