[英]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: 我正在尝试在移动6.x中创建菜单栏,这是我正在使用的代码:
Resource.h 资源.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 WM_CREATE 这是我对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;
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. 事实证明,资源编译器未定义SHMENUBAR,如果您使用向导创建项目,则将
#define SHMENUBAR RCDATA
添加到项目中。 all I had to do was to replace the SHMENUBAR with RCDATA. 我要做的就是用RCDATA代替SHMENUBAR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.