Sorry, I completely forgot about this thread,

I have been so busy with my PPL project lately.
Here is how I do it.
1. First I create a menubar resource with one menu item that is not visible.
2. When creating my form, I do this:
- Code:
HWND CreateEmptyRpCommandBar(HWND hwnd)
{
SHMENUBARINFO mbi;
memset(&mbi;, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.dwFlags = 0;
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_EMPTYMENUBAR1;
mbi.hInstRes = Instance;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
#ifdef SHCMBF_COLORBK
mbi.clrBk = 0 ; // PocketPC2002 only
#endif
if (!SHCreateMenuBar(&mbi;))
return NULL;
return mbi.hwndMB;
}
...
HWND m = CreateEmptyRpCommandBar(h);
if (m != NULL)
CommandBar_Show(m, true);
3. Then I create my menu:
- Code:
void AddMenuItem(HWND bar, int iFlags, UINT iId, UINT iValue, LPTSTR sText)
{
int iLength ; // Real length of the menu item string
TBBUTTON rButton ; // Menu item "button" on the menu bar
wchar_t *lpBuffer ; // Pointer to buffer for text of menu items
int iIndex ;
iLength = wcslen(sText) ;
lpBuffer = (wchar_t *)malloc((iLength + 2) * sizeof(wchar_t)) ;
wcscpy(lpBuffer, sText) ; // Copy the string to the buffer
lpBuffer[iLength+1] = 0;
if ((iIndex = SendMessage(bar, TB_ADDSTRING, 0, (LPARAM) lpBuffer)) == -1) // Add one string
{
char ss[255];
sprintf(ss, "Could not add menu string '%s'", ToChar(sText));
RuntimeError(ss) ;
}
free(lpBuffer) ;
// Now add a toolbar button containing the string
rButton.iBitmap = I_IMAGENONE ; // No bitmap
rButton.idCommand = iId ; // ID for WM_COMMAND
rButton.fsState = TBSTATE_ENABLED ; // Enabled button, text
rButton.fsStyle = iFlags | TBSTYLE_AUTOSIZE ; // Autosize the button, flags indicate dropdown
rButton.dwData = iValue ; // Handle to dropdown menu
rButton.iString = iIndex ; // Use this string for text
CommandBar_AddButtons(bar, 1, &rButton;);
CommandBar_DrawMenuBar(bar, 0);
}
...
HMENU newmenu = CreatePopupMenu();
#define TBSTYLE_NO_DROPDOWN_ARROW 0x0080
AddMenuItem(m, TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW, Id, (UINT)newmenu, mname);
If you have any questions, I will try to help.
Regards,
Kornalius