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 ();

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.