在CE中创建动态菜单有点问题,想问一下

soluble   2008-2-18 13:40 楼主

LRESULT DoCreateMain(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
        HWND hwndCB;

        hwndCB = CommandBar_Create(g_hInst, hWnd, IDC_CMDBAR);
        CommandBar_AddAdornments(hwndCB, 0, 0);

        HMENU hMainMenu, hMenu;

        hMainMenu = CreateMenu();
        hMenu = CreateMenu();
        AppendMenu(hMenu, MF_STRING|MF_ENABLED, 100, TEXT("&New"));
        AppendMenu(hMenu, MF_STRING|MF_ENABLED, 101, TEXT("&Open"));
        AppendMenu(hMenu, MF_STRING|MF_ENABLED, 102, TEXT("&Save"));
        AppendMenu(hMenu, MF_STRING|MF_ENABLED, 103, TEXT("E&xit"));

        AppendMenu(hMainMenu, MF_STRING|MF_ENABLED|MF_POPUP, (UINT)hMenu, TEXT("&File"));

        CommandBar_InsertMenubarEx(hwndCB, NULL, hMainMenu, 0);
        //error C2664: 'CommandBar_InsertMenubarEx' : cannot convert parameter 3 from 'HMENU' to 'LPTSTR',不能是菜单句柄吗?
        return 0;
}

回复评论 (2)

CommandBar_InsertMenubarEx(hwndCB, NULL, (LPTSTR)hMainMenu, 0);
改成这也没有效果。看不到菜单
点赞  2008-2-18 13:53
学习一下
LRESULT   DoCreateMain(HWND   hWnd,   UINT   wMsg,   WPARAM   wParam,   LPARAM   lParam)
{
HWND   hwndCB;

hwndCB   =   CommandBar_Create(g_hInst,   hWnd,   IDC_CMDBAR);


HMENU   hMainMenu,   hMenu;

hMainMenu   =   CreateMenu();
hMenu   =   CreateMenu();
AppendMenu(hMenu,   MF_STRING ?MF_ENABLED,   100,   TEXT("&New"));
AppendMenu(hMenu,   MF_STRING ?MF_ENABLED,   101,   TEXT("&Open"));
AppendMenu(hMenu,   MF_STRING ?MF_ENABLED,   102,   TEXT("&Save"));
AppendMenu(hMenu,   MF_STRING ?MF_ENABLED,   103,   TEXT("E&xit"));

AppendMenu(hMainMenu,   MF_STRING ?MF_ENABLED ?MF_POPUP,   (UINT)hMenu,   TEXT("&File"));

CommandBar_InsertMenubarEx(hwndCB,   NULL,   hMainMenu,   0);  

CommandBar_AddAdornments(hwndCB,   0,   0);  
              
return   0;
}
点赞  2008-2-19 10:41
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复