How to dynamically modify the text of menubar menu items in wince and Windows Mobile Development (original)

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.