Windows Mobile Development Summary-menu

Source: Internet
Author: User

You often need to create menus during development and dynamically display and hide menus or a sub-menu. The following is the implementation method:

1. Create and display the menu. Add the menu in the resource first, and then run the following code:

Shmenubarinfo MBI;

Zeromemory (& MBI, sizeof (shmenubarinfo ));

MBI. cbsize = sizeof (shmenubarinfo );

MBI. hwndparent = m_hwnd;

MBI. hinstres =: AfxGetInstanceHandle (); MBI. dwflags = shcmbf_hmenu | hidden; // hide sip MBI. ntoolbarid = idr_mymenu; shcreatemenubar (& MBI );

2. Hide the menu hwnd =: shfindmenubar (m_hwnd); If (hwnd! = NULL): showwindow (hwnd, sw_hide );

3. Hide a sub-menu

Tbbuttoninfo tbbi = {0 };

Tbbi. cbsize = sizeof (tbbuttoninfo );

Tbbi. dwmask = tbif_lparam | tbif_byindex;

: Sendmessagew (MBI. hwndmb, tb_getbuttoninfo, 1, (lparam) & tbbi); // 1 is softkey1, 2 is softkey2 g_hmenu = (hmenu) tbbi. lparam; // g_hmenu is a global variable, so that the sub-menu enablemenuitem (g_menu, id_test, mf_grayed) can be hidden anywhere. // hide the sub-menu

// Display the sub-menu enablemenuitem (g_menu, id_test, mf_enabled );

4. Make a softkey unavailable: shenablesoftkey (MBI. hwndmb, 0, true, false); 5. Modifymenu (g_hmenu, id_test, mf_disabled | mf_string, id_test, l "modify"); drawmenubar ();

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.