?
Solved

Menu Item

Posted on 2001-09-14
4
Medium Priority
?
262 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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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