Jump to content

Context Menu Subitem - How to?


Recommended Posts

Hi I was wandering if there`s a way to add a subitem to the context menu created by Holger...can be found here

If so..can someone show me a simple example on how to do it..

thx in advance.

It's the same as a normal menu AFAIK

$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$Menu = GUICtrlCreateMenu("Menu")
$MenuItem1 = GUICtrlCreateMenu("Item1", $Menu)
$MenuItem1s1 = _GUICtrlCreateODMenuitem("item1sub1", $MenuItem1)
$MenuItem1s2 = _GUICtrlCreateODMenuitem("item1sub2", $MenuItem1)
$MenuItem2 = _GUICtrlCreateODMenuitem("MenuItem2", $Menu)
$MenuItem3 = _GUICtrlCreateODMenuitem("MenuItem3", $Menu)
$MenuItem1 = GUICtrlCreateMenu("Menu2")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

It's the same as a normal menu AFAIK

$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$Menu = GUICtrlCreateMenu("Menu")
$MenuItem1 = GUICtrlCreateMenu("Item1", $Menu)
$MenuItem1s1 = _GUICtrlCreateODMenuitem("item1sub1", $MenuItem1)
$MenuItem1s2 = _GUICtrlCreateODMenuitem("item1sub2", $MenuItem1)
$MenuItem2 = _GUICtrlCreateODMenuitem("MenuItem2", $Menu)
$MenuItem3 = _GUICtrlCreateODMenuitem("MenuItem3", $Menu)
$MenuItem1 = GUICtrlCreateMenu("Menu2")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Hmm thx...but i think u missunderstud...i needed to know how to create a sub item for the context menu..not the menu bar...anyway thx

Link to comment
Share on other sites

Hmm thx...but i think u missunderstud...i needed to know how to create a sub item for the context menu..not the menu bar...anyway thx

Well that really makes no difference to the way to do it. Exactly the same approach but instead of a menu use ContextMenu like this

$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$But1 = GUICtrlCreateButton("",10,10,20,20)
$Menu = GUICtrlCreateContextMenu($But1);context mneu for a button
$MenuItem1 = GUICtrlCreateMenu("Item1", $Menu);for the context menu submenu
$MenuItem1s1 = _GUICtrlCreateODMenuitem("item1sub1", $MenuItem1)
$MenuItem1s2 = _GUICtrlCreateODMenuitem("item1sub2", $MenuItem1)
$MenuItem2 = _GUICtrlCreateODMenuitem("MenuItem2", $Menu)
$MenuItem3 = _GUICtrlCreateODMenuitem("MenuItem3", $Menu)
$MenuItem1 = GUICtrlCreateMenu("Menu2")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Well that really makes no difference to the way to do it. Exactly the same approach but instead of a menu use ContextMenu like this

$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$But1 = GUICtrlCreateButton("",10,10,20,20)
$Menu = GUICtrlCreateContextMenu($But1);context mneu for a button
$MenuItem1 = GUICtrlCreateMenu("Item1", $Menu);for the context menu submenu
$MenuItem1s1 = _GUICtrlCreateODMenuitem("item1sub1", $MenuItem1)
$MenuItem1s2 = _GUICtrlCreateODMenuitem("item1sub2", $MenuItem1)
$MenuItem2 = _GUICtrlCreateODMenuitem("MenuItem2", $Menu)
$MenuItem3 = _GUICtrlCreateODMenuitem("MenuItem3", $Menu)
$MenuItem1 = GUICtrlCreateMenu("Menu2")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Thx...you were a little late i`ve solved it....anyway thx for replying...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...