the menu handle is the popup handle or menu item handle?
why these question? because when i use the AppendMenu() for add a new menu item, i don't get the menu item handle. can anyone correct me, please?
i'm just trying understand it nothing more ;)
out-off topic: i need just 1 advice: can i combine the menu ID with 'this'(class instance pointer) and then separe them? or put the 'this' in some menu structure?
but the WM_MENUCOMMAND don't have the menu id (kill me in a diferent way ;) )lol
let me ask: the MENUITEMINFO have the 'this'.
so i must create a class name variable for recive the 'this' pointer, but i have several functions on class. how can i send everything to the new class variable?
1 2
CREATESTRUCT *p = (CREATESTRUCT *)s.dwItemData=this;
Menu inst = (Menu*)p->lpCreateParams;
if (fResult)
{
UINT myId = menuInfo.wID; // this is item ID
ULONG_PTR myData = menuInfo.dwItemData; // item data (like your 'this' pointer')
CREATESTRUCT *p = (CREATESTRUCT *)(ULONG_PTR)(menuInfo.dwItemData);
Menu mMenu = (Menu*)p->lpCreateParams;
mMenu->MenuClick() ;
}
1st error: conversion from 'Menu*' to non-scalar type 'Menu' requested;
2nd error: base operand of '->' has non-pointer type 'Menu'.
what i'm doing wrong?
after create the menu item:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//put the this on dwItemData
MENUITEMINFO s;
GetMenuItemInfo (hMenu,intID, true, &s);
s.cbSize=sizeof(MENUITEMINFO );
s.fMask=MIIM_DATA;
s.dwItemData=(ULONG_PTR)this;
SetMenuItemInfo (hMenu,intID, true, &s);
//change the menu for use the WM_MENUCOMMAND
MENUINFO mnInfo;
GetMenuInfo(MenuHandle,&mnInfo);
mnInfo.cbSize=sizeof(MENUINFO);
mnInfo.fMask=MIM_STYLE;
mnInfo.dwStyle=MNS_NOTIFYBYPOS;
SetMenuInfo(MenuHandle,&mnInfo);