当前位置: 代码迷 >> WinCE >> evc4.0怎么在一个dialog上添加一个菜单栏
  详细解决方案

evc4.0怎么在一个dialog上添加一个菜单栏

热度:168   发布时间:2016-04-28 13:25:19.0
evc4.0如何在一个dialog上添加一个菜单栏
我在oncreate函数里面添加没用.好象不支持 setmenu();不会做,请大侠帮忙

------解决方案--------------------
先在资源里面创建一个菜单,然后用这个函数创建,然后在oncreate里面调用
HWND CreateRpCommandBar(HWND hwnd)
{
SHMENUBARINFO mbi;

memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.nToolBarId = 你的菜单ID;
mbi.hInstRes = g_hInst;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;

if (!SHCreateMenuBar(&mbi))
return NULL;

return mbi.hwndMB;
}
------解决方案--------------------
LRESULT onCreate(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
SHMENUBARINFO mbi;

// 初始化menubar结构
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO); // 必须填充
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDR_MAIN_MENUBAR;
mbi.hInstRes = g_hInstance;

// 建立menubar控制
if (!SHCreateMenuBar(&mbi))
{
MessageBox (hWnd, _T( "建立menubar失败 "),
g_szAppName, MB_OK);
DestroyWindow(hWnd);
}

return 0;
}

------解决方案--------------------
HINSTANCE g_hInst = ::AfxGetInstanceHandle();
HWND m_hWndCB;
m_hWndCB = ::CommandBar_Create(g_hInst, m_hWnd, 1);
if (m_hWndCB != NULL)
{
//Add a menu bar
::CommandBar_InsertMenubar(m_hWndCB, g_hInst, IDR_MENU1, 0);
::CommandBar_AddAdornments(m_hWndCB, 0, 0);
}
放在初始化里。IDR_MENU1为菜单ID
------解决方案--------------------
使用CommandBar_系列函数吧
  相关解决方案