//QM v2.9. Do not edit with text editor!!! //
20    2
A_O!‘œÛízü§ý'—)¾N ØWl´w<ˆÕ—Ô
  ShowMenu  8 37F4F3CD 0
 /
function# $items [hwndowner] [POINT&where] [flags] [tpmFlags] ;;flags: 1 enable keyboard.  tpmFlags: 4 align center horz, 8 align right, 16 align center vert, 32 align bottom, ...

 Creates and shows popup menu.
 Returns selected item id or 0.
 If you need more control (disable items, etc), instead use MenuPopup class.

 items - list of menu items.
 hwndowner - owner window. Must belong to current thread.
 where - POINT variable containing menu position. Default or 0: mouse position.
 flags:
   1 - enable keyboard navigation and accelerator characters (characters preceded by &).
      If hwndowner used, this flag is not needed.
      If hwndowner not used, this flag temporarily deactivates the currently active window.
 tpmFlags - TrackPopupMenuEx flags, documented in MSDN. The constants begin with TPM_. The function adds TPM_RETURNCMD flag if not present, but removes if present.

 EXAMPLE
 str s=
  1 Text (1 is item id; Text is label)
  -
  2 Use - line for separator
  >Submenu
  	15 Tabs at the beginning are ignored
  	16 Tab in the middle	right-aligns text
  	<
  |
  25 Use | line for vertical break
  >30 Another submenu (with id)
  	31 &Ampersand (&&) underlines the character
  	-32 (separator with id)
  	Menu item id is optional
  	<
 
 int i=ShowMenu(s)
 out i


#compile "__MenuPopup"
MenuPopup m.AddItems(items)
ret m.Show(hwndowner where flags tpmFlags)

  MenuPopup  1114112 37F30414 0

  MenuPopup help  0 37F4ED72 2
 Creates and shows a popup menu.
 Also has functions to disable, check items, etc.
 A MenuPopup variable also can be used as menu handle with Windows API menu functions.

 EXAMPLES

#compile "__MenuPopup"

str s=
 1 Text (1 is item id; Text is label)
 -
 2 Use - line for separator
 >Submenu
 	15 Tabs at the beginning are ignored
 	16 Tab in the middle	right-aligns text
 	<
 |
 25 Use | line for vertical break
 >30 Another submenu (with id)
 	31 &Ampersand (&&) underlines the character
 	-32 (separator with id)
 	Menu item id is optional
 	<

MenuPopup x.AddItems(s)
int i=x.Show
out i

  or

 int i=ShowMenu(s)
 out i

  __MenuPopup  0 37F4ED5D 2
class MenuPopup -m_h

  MenuPopup.AddItems  16 37F4ED0B 2
function $items

 Adds menu items.

 items - list of menu items.

 See also: <ShowMenu>

 Example in class help.


str s=items
ARRAY(lpstr) a
if(!tok(s a -1 "[]" 1)) ret

if(!m_h) m_h=CreatePopupMenu
CreateSubmenu(m_h a)

  MenuPopup.Show  16 37F4F131 2
function# [hwndowner] [POINT&where] [flags] [tpmFlags] ;;flags: 1 enable keyboard

 Shows popup menu.
 Returns selected item id or 0.

 All arguments are as with ShowMenu.

 See also: <ShowMenu>



if(!m_h or !GetMenuItemCount(m_h)) ret

int hwnd hf r

if(hwndowner) hwnd=hwndowner
else
	_i=win
	hwnd=CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_NOPARENTNOTIFY +32770 0 WS_POPUP 0 0 0 0 _i 0 _hinst 0)
	SetForegroundWindow _i

if(flags&1)
	if(!hwndowner) hf=win
	act hwnd; err

POINT p; if(&where) p=where; else xm p

r=TrackPopupMenuEx(m_h tpmFlags^TPM_RETURNCMD p.x p.y hwnd 0)

if(!hwndowner) DestroyWindow(hwnd)
0
if(hf) act hf; err
ret r

  MenuPopup.DisableItems  16 37F3565B 2
function $items

 Disables one or more menu items.
 Call this function between AddItems and Show.

 items - list of item ids, like "3 4 7" or "1 4-7".


MultiProp(items 0)

  MenuPopup.CheckItems  16 37F35667 2
function $items

 Checks one or more menu items.
 Call this function between AddItems and Show.

 items - list of item ids, like "3 4 7" or "1 4-7".


MultiProp(items 1)

  MenuPopup.CheckRadioItem  16 37F368C1 2
function idFirst idLast idCheck

 Radio-checks menu item, and unchecks other items in the group.
 Call this function between AddItems and Show.

 idFirst - id of first item in the group.
 idLast - id of last item in the group.
 idCheck - id of item to check in the group.


CheckMenuRadioItem m_h idFirst idLast idCheck 0

  MenuPopup.DeleteItems  16 37F356A6 2
function $items

 Deletes one or more menu items.
 Call this function between AddItems and Show.

 items - list of item ids, like "3 4 7" or "1 4-7".


MultiProp(items 2)

  MenuPopup.SetBold  16 37F368C7 2
function item

 Sets default (bold) menu item.
 Call this function between AddItems and Show.

 item - item id.


SetMenuDefaultItem m_h item 0

  MenuPopup.GetItemText  16 37F3875C 2
function! item [str&s] [str&sRight]

 Gets menu item text.
 Returns 1 on success, 0 on failure (if id invalid).

 item - item id. If <=0, item index.
 s - receives text. If sRight used, receives only the left-aligned part. Can be 0.
 sRight - receives the right-aligned part of text. Can be 0.


str ss
if(&s) s.all; else &s=ss
if(&sRight) sRight.all

if(!MenuGetString(m_h item &s)) ret

if &sRight
	int i=findc(s 9)
	if(i>=0)
		sRight=s+i+1
		s.fix(i)
ret 1

  private  65600 37F387EC 2

  MenuPopup.  16 37F30464 13
if(m_h) DestroyMenu(m_h)

  MenuPopup.CreateSubmenu  48 37F35A54 13
function# hm ARRAY(lpstr)&a [i]

MENUITEMINFOW mi
int vert
lpstr s

for i i a.len
	s=a[i]; rep() if(s[0]=9) s+1; else break
	
	memset &mi 0 sizeof(mi); mi.cbSize=sizeof(mi); mi.fMask=MIIM_TYPE|MIIM_ID
	
	sel s[0]
		case '-': s+1; mi.fType=MF_SEPARATOR
		case '|': vert=MFT_MENUBARBREAK; continue
		case '>':
			mi.hSubMenu=CreatePopupMenu
			i=CreateSubmenu(mi.hSubMenu a i+1)
			s+1; mi.fMask|MIIM_SUBMENU
		case '<': break
	
	mi.wID=val(s 0 _i)
	if(_i) s+_i; if(s[0]=32) s+1

	if(mi.fType!MF_SEPARATOR) mi.dwTypeData=@s
	mi.fType|=vert; vert=0
	InsertMenuItemW(hm 0xffff 1 &mi)

ret i

  MenuPopup.MultiProp  48 37F4ADB4 13
function $items prop ;;prop: 0 disable, 1 check, 2 delete, 3 bold

 items - list of item ids, like "3 4 7" or "1 4-7".


ARRAY(lpstr) a; int i j k
tok items a -1 " "
for i 0 a.len
	lpstr s=a[i]
	j=val(s 0 k); if(!k) continue
	if(s[k]!'-') k=j; else k=val(s+k+1); if(k<j) continue
	for j j k+1
		sel prop
			case 0 EnableMenuItem m_h j MF_GRAYED
			case 1 CheckMenuItem m_h j MF_CHECKED
			case 2 DeleteMenu m_h j 0

  test  1114112 37F4AC74 0

  MenuPopup disable, check, etc  0 37F4ED77 17
out
#compile "__MenuPopup"

str s=
 1 normal
 2 disabled
 3 checked
 -
 4 radio group
 5 radio group, checked
 6 radio group
 -
 7 delete
 8 delete
 9 delete
 10 bold
 11 left-text	right-text


MenuPopup m.AddItems(s)

m.DisableItems("2")
m.CheckItems("3")
m.CheckRadioItem(4 6 5)
m.DeleteItems("7-9")
m.SetBold(10)

int i=m.Show
out i

str s1 s2
if(i and m.GetItemText(i s1 s2))
	out s1
	out s2

  file  268500992 0

  