Sign in to follow this  
Followers 0
ezzetabi

Updating a context menu...

3 posts in this topic

How can I update a context menu items if I can not delete the control and recreate it?

I'd like to make a context menu with a list of all active processes. Of course the list should be done on the fly when the users clicks.

But my script as now will just adds a second list in the front of the old one! How can I replace it? :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I just delete the individual one to replace it, but maybe you mean something different. This example changes it when hotkey is pressed.

I know you said

How can I update a context menu items if I can not delete the control and recreate it?

I will look to see if I can update the control in some other way, maybe command control or something.

GUICreate("My GUI Context Menu",300,200)
#include "GUIConstants.au3"
HotKeySet("{PAUSE}","TESTER")
$contextmenu = GUICtrlCreateContextMenu ()
$newsubmenu  = GUICtrlCreateMenu ("new", $contextmenu)
$textitem    = GUICtrlCreateMenuitem ("text",$newsubmenu)
$fileitem = GUICtrlCreateMenuitem ("Open",$contextmenu)
$saveitem = GUICtrlCreateMenuitem ("Save",$contextmenu,1)
GUICtrlCreateMenuitem ("",$contextmenu)  ; separator

$infoitem = GUICtrlCreateMenuitem ("Info",$contextmenu)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
    
FUNC TESTER()
   GUICtrlDelete ($saveitem )
   $saveitem = GUICtrlCreateMenuitem ("Save On close",$contextmenu,1)
   ToolTip($SAVEITEM)
   EndFunc
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Thanks scriptkitty.

I used this, for seeing actually the menu changing...

FUNC TESTER()
  GUICtrlDelete ($saveitem )
  $saveitem = GUICtrlCreateMenuitem (Random(),$contextmenu,1)
  ToolTip($SAVEITEM)
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0