Solved

Menu Item

Posted on 2001-09-14
4
261 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
[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
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6484154
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
ID: 6484406
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
ID: 6490309
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
ID: 6490348
Dan;

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

Thanks
Matt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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