Jump to content

hqprog

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by hqprog

  1. Thanks PaulIA - This is helpful and I did check it twice. It looks to me like the library refers to the AutoIt function below My issue rather seems to be with trying to get proper syntax of the direct DllCall for AppendMenu (original Modcalc.au3) vs my desired modification using InsertMenu I'm trying to get the BYPOSITION and to work together with the POPUP flag When using POPUP flag only the newmenu appears ok but doesnt add the handle of the popup window, which is needes in the subsequent lines ; Original using AppendMenu (works fine) DllCall("user32.dll","int","AppendMenu","hwnd",$hMenuTarget,"int",$MFT_POPUP,"hwnd",$hSubMenuTarget,"str","&NewMenu") ; Desired modification using InsertMenu and MF_BYPOSITION ; this use of InsertMenu shows newmenu in correct position but no submenus ;;; returns ControlID 16 to console: DllCall("user32.dll","int","InsertMenu","hwnd",$hMenuTarget,"int",2,"int",$MF_BYPOSITION,"int",$MFT_POPUP,"str","&NewMenu") ; this use of InsertMenu causes fatal crash ; unable to execute DllCall; DllCall("user32.dll","int","InsertMenu","hwnd",$hMenuTarget,"int",2,"int",$MF_BYPOSITION,"int",$MFT_POPUP,"hwnd",$hSubMenuTarget,"str","&NewMenu") ; This function from A3LMenu.au3 ; #FUNCTION# ===================================================================================================== ; Description ...: Inserts a new menu item at the specified position in a menu ; Parameters ....: $hMenu - Handle of the menu ; $iItem - Position of the menu item before which to insert the new item ; $tInfo - _tagMENUITEMINFO structure ; $fByPos - If True, $iItem is a menu item position otherwise it is a menu item identifier. ; Return values .: Success - True ; Failure - False ; Author ........: Paul Campbell (PaulIA) ; Remarks .......: ; Related .......: _Menu_AddMenuItem, _tagMENUITEMINFO ; ==================================================================================================== Func _Menu_InsertMenuItem($hMenu, $iItem, ByRef $tInfo, $fByPos=True) Local $pInfo, $aResult $pInfo = _tagGetPtr($tInfo) $aResult = DllCall("User32.dll", "int", "InsertMenuItem", "hwnd", $hMenu, "int", $iItem, "int", $fByPos, "ptr", $pInfo) Return $aResult[0] <> 0 EndFunc
  2. Hi y'all, I found wonderful code from picasso, Modded Calculator that appends newmenu items to a menu using DllCall to user32.dll in same thread I made a post about trying to use it with InsertMenu rather than AppendMenu to enable position of the newly inserted menu items. It works partly but popup submenu does not work yet - - - Been studying the MSDN documentation without success so far... any directions would be much appreciated -hq
  3. 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
  4. Hi Piccaso, The hook.dll approach is very nice and I might use it - but it would be nice to use BYPOSITION to create menuitem anywhere rather than just append at end It appear the dll may support other functions besides "AppendMenu" such as "Insert Menu" and possibly others (?) Is there some documentation of the dll available? Thanks.
  5. The Modded Calculator is a _very_ nice way to add a menu item. Could someone tell me if adding a menu item also possible with ANYGUI.au3 or does that add controls just to the window application area below the title and menubar? Thank you.
×
×
  • Create New...