So basically, I am trying to check a menu item that belongs in a cascading submenu. I have a sample diagram to show you want I mean. I am sure I am getting the handle because I get get the string, but I just can't put a check mark there. I want to check mar Item2 and Item1.
(Submenu Bar ) Item1 Item2
^
|
(Submenu Bar ) Add Subtract Mutiply Divide Opts
^
|
(Main Menu Bar )Close Edit Tools
////////////////////////////MY CODE////////////////////////////
CMenu* mmenu = GetDialogMenu();
CMenu* submenu = mmenu->GetSubMenu(1); CMenu* sub_submenu= submenu->GetSubMenu(0);sub_submenu->GetMenuString(1,str_temp,MF_BYPOSITION );
sub_submenu->CheckMenuItem( 1, MF_CHECKED | MF_POSITION);

Can't Check Submenu Item
genius15
Thanks for the tip, but I think we may disagree.
I can't say I entirely agree with you comments. In regards to the wrapper function. If I bring item1 and item 2 down to the firt submenu, I can add the check box. Meaning, item1 and item2 is on the same level at "Add Subtract Mutiply Divide Opts."
If GetDialogMenu was just a wrapper function, then when I bring down item1 and item2 to a lower submenu, it would still mean I couldn't add the check. But in my case, I can.
Had anyone else got cascading submenus to work correctly yet
Ahmed Abd-ElHaffiez
NormanL
ReneeB
The actually submenu of the submenu is this section of code,
......
POPUP "Tools"
BEGIN
POPUP
"Options"BEGIN
MENUITEM
"Check for Overlapping Points", ID_OPTS_CHECKFORPTOVERLAPMENUITEM
"Input 3D Measurements", ID_OPTS_INPUT3DMEASUREMENTSEND
......
M Roy
bool
CDialogCEShared::AddCustomToolbarButtons( CToolBarCtrl* pToolBarCtrl, int& iRightIndex ){
UINT dwDlgMenuID = GetDlgMenuID();
if ( dwDlgMenuID != 0 )
{
m_wndCommandBar.InsertMenuBar( dwDlgMenuID );
m_hDlgMenu = m_wndCommandBar.GetMenu();
}
Jag711
jy_lam
// menu functionality
HMENU m_hDlgMenu;
CMenu* GetDialogMenu() {
return ( m_hDlgMenu != NULL ) CMenu::FromHandle( m_hDlgMenu ) : NULL; }gpetrosh
This worked for me; I was able to place a check mark before the 2nd entry in the options menu.
TBBUTTON tbb;
::SendMessageW(m_wndCommandBar.m_hCommandBar, TB_GETBUTTON,1,(LONG) (LPARAM)&tbb);
TBBUTTONINFO tbbi = {0};
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_LPARAM | TBIF_COMMAND;
::SendMessageW(m_wndCommandBar.m_hCommandBar,TB_GETBUTTONINFO,
tbb.idCommand, (LPARAM)&tbbi);
HMENU hMenu = (HMENU)tbbi.lParam;
CMenu* mmenu = CMenu::FromHandle(hMenu);
CMenu* sub_submenu= mmenu->GetSubMenu(0);
CString str_temp;
sub_submenu->GetMenuString(1,str_temp,MF_BYPOSITION );
sub_submenu->CheckMenuItem( 1, MF_CHECKED | MF_BYPOSITION);
For resons why we need to do it like this, refer to these threads.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=338409&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=226853&SiteID=1
Thanks
Hilarion
GetDialogMenu is a method I created myself. It essential is like GetMenu(), it returns the handle to the main menu bar. I am quite certain that I am getting the correct handle to the submenut of the submenu. I can even use GetMenuString and get the string of the menu item. So I am sure its not some null pointer.
Any thoughts Has anyone even have such menu system in their system
shantanu_gadgil
Sorry for the delay. I was away from work for some time. Can you post the main steps in the implementation of GetDialogMenu I shall try to create a repro and then get back to you, ASAP.
Thanks
metamata
How do you assign the value to m_hDlgMenu GetDialogMenu is just a wrapper function and shouldn't effect the functionality.
Thanks
Avinash
Fredriko
Hi,
How are you creating this menubar Can you post the menu resources, including the SHMENUBAR resource from the RC2 file, if you are using it
One more thing which class has GetDialogMenu as a method
Thanks
Larry Bynum
IDR_ENTERLINEDLGMENU MENU DISCARDABLE
BEGIN
POPUP
"Edit"BEGIN
MENUITEM
"&Redo", ID_EDIT_REDOMENUITEM SEPARATOR
MENUITEM
"&Change...", ID_EDIT_CHANGEMENUITEM
"&Insert...", ID_EDIT_INSERTPOPUP
"&Delete"BEGIN
MENUITEM
"Delete Points...", ID_DELETE_POINTSMENUITEM
"Delete Line...", ID_DELETE_LINESMENUITEM
"Delete Arc...", ID_DELETE_ARCSMENUITEM
"Del. Offset Points...", ID_DELETE_OFFSETPOINTSMENUITEM
"Del. Pts. Pattern...", ID_DELETE_POINTSPATTERNEND
MENUITEM SEPARATOR
MENUITEM
"Check &Lines", ID_EDIT_ENTEREDLINESEND
POPUP
"Tools"BEGIN
POPUP
"Options"BEGIN
MENUITEM
"Check for Overlapping Points", ID_OPTS_CHECKFORPTOVERLAPMENUITEM
"Input 3D Measurements", ID_OPTS_INPUT3DMEASUREMENTSEND
MENUITEM
"&Perform Closure Check...", ID_TOOLS_CLOSURECHECKMENUITEM
"&Insert Point Pattern...", ID_TOOLS_POINTPATTERN_INSERTMENUITEM SEPARATOR
POPUP
"Change &Elevation"BEGIN
MENUITEM
"&Find && Replace...", ID_TOOLS_CHANGE_ELEV_FINDREPLACEMENUITEM
"Individual Points...", ID_TOOLS_CHANGE_ELEV_INDIVIDUALPTEND
MENUITEM
"&Enter an Arc...", ID_TOOLS_ENTERANARCMENUITEM
"Create &Line Intersection...", ID_TOOLS_LINEINTERSECTIONMENUITEM
"Create Line &Mid-point...", ID_TOOLS_MIDPOINTOFLINEPOPUP
"&Offset Points..."BEGIN
MENUITEM
"Offset From a Line...", ID_TOOLS_MULT_OFFSETPOINTSMENUITEM
"Offset from a Polyline...", ID_TOOLS_OFFSETPOINTS_FROM_ANALIGNMENTMENUITEM
"Line Down And Out...", IDC_TOOLS_DOWN_AND_OUT_PTMENUITEM
"Arc Down and Out...", ID_TOOLS_OFFSETPOINTS_ARC_DOWNANDOUTMENUITEM
"Two Tapes Intersection...", ID_TOOLS_TWO_TAPES_INTERSECTEND
MENUITEM
"Co&nnect Points...", ID_TOOLS_CONNECTPOINTSMENUITEM SEPARATOR
MENUITEM
"&Calculator...", ID_TOOLS_CALCULATOREND
END
Seaman Jiang
Thanks