Friday, October 31, 2008

Windows Mobile API ToolBar

Today I'd like to make some suggestion about CCommandBar class for Windows Mobile 5.0.
Actually when you need a menu in MFC application you should use it or native WINAPI function to have access to the ToolBar

CCommandBar class has no API to access to menu items and don't know how to operate to them so after brief investigation and experiments with menu I have got working code:
 ::SendMessage(      m_oCommandBar.GetSafeHwnd(),     TB_GETBUTTON, 1, (LPARAM)&tbb);
 HMENU hMenu=HMENU(tbb.dwData);
     ::DeleteMenu(hMenu,0,MF_BYPOSITION);     ::InsertMenu(hMenu,0,MF_BYPOSITION, ID_MENU_FR_SHOWDETAILS, L"Show Details");

Here m_oCommandBar is an instance of CCommandBar.With this trick you can access to WINAPI menu to create dynamic menus :-)

No comments: