I tried a lot of methods. I found on the Internet that I used the shgetsubmenu () method to obtain the hmenu, but I did not find this function in aygshell. h. Try to use shgetmenu (), but all obtained results are null. Finally, I found the method to obtain the hmenu handle of menubar on the Internet:
First, create a menu for the corresponding softkey.
Shmenubarinfo * SMB = new shmenubarinfo ();
SMB-> cbsize = sizeof (shmenubarinfo );
SMB-> hinstres =: AfxGetInstanceHandle ();
SMB-> hwndparent = m_hwnd;
SMB-> ntoolbarid = idr_dayplanstart;
SMB-> nbmpid = 0;
SMB-> cbmpimages = 0;
SMB-> dwflags = shcmbf_hmenu | shcmbf_hidesipbutton;
Shcreatemenubar (SMB );
Then, you can directly Save the handle, or use shfindmenubar () to find the handle and obtain the corresponding menu handle using the following method.
Hwnd hwndmb = SMB-> hwndmb;
Tbbuttoninfo tbbi = {0 };
Tbbi. cbsize = sizeof (tbbi );
Tbbi. dwmask = tbif_lparam | tbif_byindex;
: Sendmessage (hwndmb, tb_getbuttoninfo, 0, (lparam) & tbbi );
Hmenu m_hmenubar = (hmenu) tbbi. lparam;
Finally, use the menu handle to modify the menu items.
Tchar szdrawtext [100];
Wcscpy (& szdrawtext [0], schangetext); schangetext is of the cstring type. Note that the length cannot exceed the length defined by szdrawtext.
Menuiteminfo MII;
Memset (char *) & MII, 0, sizeof (MII ));
MII. cbsize = sizeof (MII );
MII. fmask = miim_type;
MII. dwtypedata = & szdrawtext [0];
MII. CCH = 100;
MII. FTYPE = mft_string;
Getmenuiteminfo (m_hmenubar, id_takephoto, false, & MII); // obtain menu item information
Setmenuiteminfo (m_hmenubar, id_takephoto, false, & MII); // set menu item information
Id_takephoto is the ID of the menu item.