Code Repo    |     RSS
MD's Technical Sharing



Tuesday, November 4, 2008

Display soft-key menu in a dialog box:

The menu needs to be created via VS Resource Editor first and the ID set to IDR_MENU1.


SHMENUBARINFO mbi;

memset(&mbi, 0, sizeof(SHMENUBARINFO));

mbi.cbSize = sizeof(SHMENUBARINFO);

mbi.hwndParent = hwndDlg;

mbi.nToolBarId = IDR_MENU1;

mbi.dwFlags |= SHCMBF_HMENU;

mbi.hInstRes = g_hinstModule;

SHCreateMenuBar(&mbi);


g_hinstModule is the handle to the module containing the resource. It can be retrieved via GetModuleHandle() or via AfxGetInstanceHandle() if MFC is used.


hwndDlg is the handle of the dialog box to bind the menu too.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.