Hello.
I want to make a dynamic menu with an icon.
Please teach a method.
CPoint cPointPop; ///< PopupMenu表示位置
CMuPopupMenuWnd *pPopup = new CNxfPopupSelElem;
pPopup->CreatePopupMenu(
//GetSafeHwnd()
AfxGetMainWnd()->GetSafeHwnd()
);
CMenu menuWidthCommands;
CMenu popupMenu;
CMenu popupMenu2;
BOOL bCreate;
bCreate = menuWidthCommands.CreateMenu();
bCreate = popupMenu.CreatePopupMenu ();
bCreate = popupMenu2.CreatePopupMenu ();
bCreate = popupMenu.AppendMenu ( MF_STRING 32123 , "aaaa" );
bCreate = popupMenu.AppendMenu ( MF_STRING, 32124 , "bbbb" );
bCreate = popupMenu2.AppendMenu ( MF_STRING, 32125 , "cc" );
bCreate = popupMenu2.AppendMenu ( MF_STRING, 32126 , "dd" );
bCreate = popupMenu.AppendMenu ( MF_POPUP, ( UINT ) popupMenu2.Detach (), "メニュー" );
bCreate = menuWidthCommands.AppendMenu ( MF_POPUP, ( UINT ) popupMenu.Detach (), "_POPUP_" );
pPopup->UpdateFromMenu(
//GetSafeHwnd() ,
AfxGetMainWnd()->GetSafeHwnd() ,
&menuWidthCommands
);
::GetCursorPos( &cPointPop );
pPopup->TrackPopupMenu (
TPMX_NO_HIDE_RARELY | // すべてPopupMenuが表示される形で起動する。
TPM_RIGHTBUTTON |
TPM_TOPALIGN |
TPM_LEFTALIGN ,
cPointPop.x ,
cPointPop.y
);