Solved

Menu Item

Posted on 2001-09-14
4
259 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

830 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