开发者

Creating menu bar in mobile 6.x

I am trying to create a menu bar in mobile 6.x and here is the code I am using:

Resource.h

#pragma once

#include <aygshell.h>

#define IDI_APP_ICON  1
#define IDR_MENU      100

#define IDS_APP_TITLE 101
#define IDS_EXIT      102
#define IDS_SEARCH    103
#define IDS_SETTINGS  104
#define IDS_HELP      105

#define IDM_EXIT      200
#define IDM_SEARCH    201
#define IDM_SETTINGS  202
#define IDM_HELP      203
#define ID_HELP_ABOUT 204

and the resource file looks like this:

#include "Resource.h"

IDI_APP_ICON ICON "AppIcon.ico"


STRINGTABLE  
BEGIN
    IDS_APP_TITLE "My App"
    IDS_EXIT      "Exit"
    IDS_SEARCH    "Search"
    IDS_SETTINGS  "Settings"
    IDS_HELP      "Help"
END

IDR_MENU MENU
BEGIN
   POPUP "Help"
     BEGIN
        MENUITEM "About", ID_HELP_ABOUT
     END
END

IDR_MENU SHMENUBAR DISCARDABLE
BEGIN
    IDR_MENU,
    4,

    I_IMAGENONE, IDM_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_EXIT, 0, NOMENU,
    I_IMAGENONE, IDM_SEARCH, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_SEARCH, 0, NOMENU,
    I_IMAGENONE, IDM_SETTINGS, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_SETTINGS, 0, NOMENU,
    I_IMAGENONE, IDM_HELP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_HELP, 0, 0,
END

and here is what I do in responce to W开发者_JAVA技巧M_CREATE

SHMENUBARINFO   mbi;

memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize     = sizeof(SHMENUBARINFO);
mbi.hwndParent = hParent; // handle to the main window
mbi.nToolBarId = IDR_MENU;
mbi.hInstRes   = g_hInst;
mbi.dwFlags    = SHCMBF_HMENU | SHCMBF_HIDESIPBUTTON;

if (SHCreateMenuBar(&mbi))
    g_hWndMenuBar = mbi.hwndMB;
else
    g_hWndMenuBar = NULL;

but only the Help menu shows up on the left side. anyone knows why?


I found the answer. It turns out that SHMENUBAR is not defined by the resource compiler and if you create your project using wizard, if will add #define SHMENUBAR RCDATA to the project. all I had to do was to replace the SHMENUBAR with RCDATA.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜