Sign in to follow this  
Followers 0
Achilles

Right clicking

5 posts in this topic

I've noticed that for most things you right click it brings up a menu with a list of all the things you can do. Is there a way you make these for our programs? It seems like it would kind of be the same things as a filemenu or traymenu, but both of those are in set positions...

Any help/ideas appreciated!

And on another note does anybody know how to make tray items bold?


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



You want to use GuiCtrlCreateContextMenu and GuiCtrlCreateMenuItem. Here's an example:

#include <GUIConstants.au3>

GUICreate('', 80, 150)
$lable1 = GUICtrlCreateLabel('', 10, 10, 60, 60)
GUICtrlSetBkColor(-1, 0x00FF00)

$lable2 = GUICtrlCreateLabel('', 10, 80, 60, 60)
GUICtrlSetBkColor(-1, 0xFF0000)

$menu1 = GUICtrlCreateContextMenu($lable1)
$m1i1 = GUICtrlCreateMenuitem('label 1 item 1', $menu1)
$m1i2 = GUICtrlCreateMenuitem('label 1 item 2', $menu1)

$menu2 = GUICtrlCreateContextMenu($lable2)
$m2i1 = GUICtrlCreateMenuitem('label 2 item 1', $menu2)
$m2i2 = GUICtrlCreateMenuitem('label 2 item 2', $menu2)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $m1i1
            MsgBox(0, '', 'label 1 item 1')
        Case $m1i2
            MsgBox(0, '', 'label 1 item 2')
        Case $m2i1
            MsgBox(0, '', 'label 2 item 1')
        Case $m2i2
            MsgBox(0, '', 'label 2 item 2')
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

You want to use GuiCtrlCreateContextMenu and GuiCtrlCreateMenuItem. Here's an example:

#include <GUIConstants.au3>

GUICreate('', 80, 150)
$lable1 = GUICtrlCreateLabel('', 10, 10, 60, 60)
GUICtrlSetBkColor(-1, 0x00FF00)

$lable2 = GUICtrlCreateLabel('', 10, 80, 60, 60)
GUICtrlSetBkColor(-1, 0xFF0000)

$menu1 = GUICtrlCreateContextMenu($lable1)
$m1i1 = GUICtrlCreateMenuitem('label 1 item 1', $menu1)
$m1i2 = GUICtrlCreateMenuitem('label 1 item 2', $menu1)

$menu2 = GUICtrlCreateContextMenu($lable2)
$m2i1 = GUICtrlCreateMenuitem('label 2 item 1', $menu2)
$m2i2 = GUICtrlCreateMenuitem('label 2 item 2', $menu2)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $m1i1
            MsgBox(0, '', 'label 1 item 1')
        Case $m1i2
            MsgBox(0, '', 'label 1 item 2')
        Case $m2i1
            MsgBox(0, '', 'label 2 item 1')
        Case $m2i2
            MsgBox(0, '', 'label 2 item 2')
    EndSwitch
WEnd
Sweet, thanks! That's exactly what I was looking for I just didn't know they were called context menus... :)

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

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