Saturday, January 16, 2016

How to Expand Menu under WinCE




            


Recently DirectShow need to design a Camera application, in order to beautify the interface want to extend these components out of trouble when expanding CMenu, first discovered in the WinCE GetMenuItemID have Bug, to MF_POPUP type submenu return value -1 is not described in this document , but the menu handle. Since then good detour through GetSubMenu first determine whether the Pop menu and then determine whether the separator bar or normal menu.
Now want to override the LoadMenu, resource loading process will set its Style MF_OWNERDRAW, then reload DrawItem, but now found the wrong time is displayed as long as the Style is set to MF_OWNERDRAW, TrackPopupMenuEx function call, which is MF_STRING it is normal, does the problem lie? Here is my LoadMenu function call is used to modify the style function, I was through AppendMenu loaded one by one menu item:
void CSXMenu :: ChangeMenuStyle (CMenu * pMenu, HMENU hMenu)
{

if (pMenu == NULL)
return;

UINT nItemID = 0;
CMenu * pTempMenu = NULL;
int nCount = (int) pMenu- & gt; GetMenuItemCount ();
for (int i = 0; i & lt; nCount; i ++)
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof (MENUITEMINFO);

// Because the bug of GetMenuItemID, have to use GetSubMenu
pTempMenu = pMenu- & gt; GetSubMenu (i);
if (pTempMenu == NULL)
{
// No Pop Menu, So It's a Normal Menu or Separator
nItemID = pMenu- & gt; GetMenuItemID (i);
if (nItemID == 0)
{
// Separator Item
CMenuItem * pMenuItem = new CMenuItem;
:: AppendMenu (hMenu, MF_SEPARATOR, 0, (LPCTSTR) pMenuItem);

// :: ModifyMenu (hMenu, i, MF_BYPOSITION | MF_OWNERDRAW, -1, (LPCTSTR) pMenuItem);

#if 0
menuInfo.fMask = MIIM_TYPE;
pMenu- & gt; GetMenuItemInfo (i, & amp; menuInfo, TRUE);
menuInfo.fType = MFT_OWNERDRAW;
menuInfo.dwItemData = * test;
pMenu- & gt; SetMenuItemInfo (i, & amp; menuInfo, TRUE);

No comments:

Post a Comment