Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error in PopupMenuCreate
#1
Flags for submenu items (e.g. ">Submenu1") do not work.
The flag for the last item in the submenu (e.g. "Last item of Submenu1<") is applied to the ">Submenu1" item.

The following code works as it should (changes are indicated in starred remarks).
Function PopupMenuCreate2
Code:
Copy      Help
;/
function# &i str&items lpstr'fa [FINDWORDN*getlstate]

str ss.flags=1
lpstr s
int vert hm=CreatePopupMenu()
MENUITEMINFOW mii.cbSize=sizeof(MENUITEMINFOW)
if(getlstate) _getl=*getlstate

for i i 1000000
,vert=0
,;g2
,if(ss.getl(items -i)<0) break
,for(s ss s+ss.len) if(s[0]!9) break ;;skip tabs
,mii.fMask=MIIM_TYPE|MIIM_ID|MIIM_STATE
,mii.fState=0; mii.dwTypeData=0; mii.fType=MF_STRING|vert
,sel s[0]
,,case '-' mii.fType=MF_SEPARATOR|vert
,,case '|' vert=MF_MENUBARBREAK; i+1; goto g2
,,case '>'
,,,mii.fMask=MIIM_TYPE|MIIM_SUBMENU|MIIM_STATE
,,,mii.dwTypeData=@(s+1)
,,,if(fa) ;;******added this******
,,,,int flags=fa[i] ;;******added this******
,,,,if(flags&1) mii.fState|MF_DISABLED|MF_GRAYED ;;******added this******
,,,,if(flags&2) mii.fState|MF_CHECKED ;;******added this******
,,,,if(flags&4) mii.fType|MFT_RADIOCHECK ;;******added this******
,,,i+1
,,,mii.hSubMenu=PopupMenuCreate(&i &items fa &_getl)
,,,;goto g1 ;;******not needed******
,,case '<' i-1; goto gr
,,case else
,,mii.dwTypeData=@s
,,;g1 ;;******not needed******
,,if(fa)
,,,int flags=fa[i]
,,,if(flags&1) mii.fState|MF_DISABLED|MF_GRAYED
,,,if(flags&2) mii.fState|MF_CHECKED
,,,if(flags&4) mii.fType|MFT_RADIOCHECK
,mii.wID=i+1
,InsertMenuItemW(hm 65000 0 &mii)
;gr
if(getlstate) *getlstate=_getl
ret hm


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)