windows - How to append a dynamic menu item after call CMenu::LoadMenu? -


In my project, there is a menu that should be dynamically added to an item in the original code, the items in the menu are static The menu is defined in the resource file:

  IDM_SERVER_OPTIONS menu unacceptable BEGIN POPUP "" BEGIN menu "and" Connect ", IDC_LAUNCHITEM_CONNECT MENUITEM" & amp; Delete ", IDC_REMOVE_SERVER END END   

and is loaded into the code:

  Seamen menu; Menu.LoadMenu (IDM_SERVER_OPTIONS);   

Now, after loading the resource menu there is a new requirement to attach a dynamic menu item. I said this horoscope: After this, I wrote this code: < Pre> seamen menu; Menu.LoadMenu (IDM_SERVER_OPTIONS); CMenu * autoConnectMenu = new CMenu; AutoConnectMenu- & gt; CreatePopupMenu (); AutoConnectMenu- & gt; APPENDENMU (MF_DE | MF_ANNELELD, IDC_MMU_AUTOONCTERAR, UTLL :: LOADSTRING (IDS_MANU_AUTOONERER); Menu.AppendMenu (MF_POPUP, (UINT) Autoconnect menu-> m_hMenu, L "Auto Connect Server");

Unfortunately, the new menu item "Auto Connect Server" can not be displayed if it does not work. Then, I tried the HMENU function:

  the semen menu; Menu.LoadMenu (IDM_SERVER_OPTIONS); AppendMenu ((HMEU) menu. GetSubMenu (0), MF_String | MF_ANNABADD, IDC_AUTOONECCTAR, UTIL :: LoadString (IDS_MANU_AUTOONERER);   

It works fine!

What do I want to know in my previous code? Appreciate!

I think I got the problem. I should have called the

  menu. Gatesbymanu (0) - & gt; Append menu (...); Instead of   

  menu.AppendMenu (...);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -