在mobile 6.x中创建菜单栏

时间:2011-04-04 15:28:09

标签: c++ mobile resources

我正在尝试在mobile 6.x中创建一个菜单栏,这是我正在使用的代码:

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

,资源文件如下所示:

#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

以下是我对WM_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;

但只有左侧显示“帮助”菜单。有谁知道为什么?

1 个答案:

答案 0 :(得分:0)

我找到了答案。事实证明,资源编译器并未定义SHMENUBAR,如果使用向导创建项目,则会将#define SHMENUBAR RCDATA添加到项目中。我所要做的就是用RCDATA代替SHMENUBAR。