To be more specific, I'm trying to modify the code of ModCalc.au3 as shown below
I changed the DllCall to use the InsertMenu command with $MF_BYPOSITION
Is the DllCall for InsertMenu configured properly? (it appears to work ok)
However I cannot get the submenus to popup - so am not sure the submenu handle is correctly configured
Should the InsertMenu command also be used for DllCall for submenus?
Or something more I am missing in the MSDN documentation on menus
Any suggestions would be much appreciated
Cheers!
; ORIGINAL from ModCalc.au3
; Add new PopupMenu
$hSubMenuTarget = DllCall("user32.dll","hwnd","CreatePopupMenu")
$hSubMenuTarget = $hSubMenuTarget[0]
DllCall("user32.dll","int","AppendMenu","hwnd",$hMenuTarget,"int",$MFT_POPUP,"hwnd",$hSubMenuTarget,"str","&NewMenu")
; Add our menuitem
$MENUID = 380 ;Unique ControlID to be created
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_STRING,"int",$MENUID,"str","New&Item")
; Add a Separator
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_SEPARATOR,"int",1,"str","")
$MENUID_REMOVE = 382 ;Unique ControlID to be created
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_STRING,"int",$MENUID_REMOVE,"str","Remove &Modification")
DllCall("user32.dll","int","DrawMenuBar","hwnd",$hWndTarget) ; Redraw Menu
; MODIFIED
; Add new PopupMenu
$hSubMenuTarget = DllCall("user32.dll","hwnd","CreatePopupMenu")
$hSubMenuTarget = $hSubMenuTarget[0]
DllCall("user32.dll","int","InsertMenu","hwnd",$hMenuTarget,"int",2,"int",$MF_BYPOSITION,"int",$MFT_POPUP,"str","&NewMenu") ; CHANGED to InsertMenu BYPOSITION
; Add our menuitem
$MENUID = 380 ;Unique ControlID to be created
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_STRING,"int",$MENUID,"str","New&Item")
; Add a Separator
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_SEPARATOR,"int",1,"str","")
$MENUID_REMOVE = 382 ;Unique ControlID to be created
DllCall("user32.dll","int","AppendMenu","hwnd",$hSubMenuTarget,"int",$MFT_STRING,"int",$MENUID_REMOVE,"str","Remove &Modification")
DllCall("user32.dll","int","DrawMenuBar","hwnd",$hWndTarget) ; Redraw Menu