Sign in to follow this  
Followers 0
Enforcer

TreeView and ContextMenu

5 posts in this topic

Have 2 different treeview items which contains subitems like Item 1 and item 2 in it... Simply need to create 2 different context menu...

Like in picture ITEM1 and all items from "ALL USERS" must have 1 context menu

and Item2 and all items from "Friends" must have second context menu

Please look at picture to understend what i mean...

Realy don't know how to do this, and need some help...

post-22665-1200785633_thumb.png


[RU] Zone

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
#include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$MainGUI = GUICreate("TreeView", 185, 297, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainGUIClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainGUIMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainGUIMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "MainGUIRestore")
$TreeView1 = GUICtrlCreateTreeView(8, 8, 169, 249)
GUICtrlSetOnEvent(-1, "TreeView1Click")
$Close = GUICtrlCreateButton("Close", 56, 264, 75, 25, 0)
GUICtrlSetOnEvent(-1, "MainGUIClose")

$hAllUser = _GUICtrlTreeView_Add ($TreeView1, 0, 'All User')
_GUICtrlTreeView_AddChild ($TreeView1, $hAllUser, 'ITEM1')

$hFriends = _GUICtrlTreeView_Add ($TreeView1, 0, 'Friends')
_GUICtrlTreeView_AddChild ($TreeView1, $hFriends, 'ITEM2')

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func MainGUIClose()
    Exit
EndFunc

Func MainGUIMaximize()

EndFunc

Func MainGUIMinimize()

EndFunc

Func MainGUIRestore()

EndFunc

Func TreeView1Click()

EndFunc


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Have 2 different treeview items which contains subitems like Item 1 and item 2 in it... Simply need to create 2 different context menu...

Like in picture ITEM1 and all items from "ALL USERS" must have 1 context menu

and Item2 and all items from "Friends" must have second context menu

Please look at picture to understend what i mean...

Realy don't know how to do this, and need some help...

Darova! :D This not hard:

#include <GuiConstants.au3>

$hGui = GUICreate("TreeView context menu", 300, 200)

$iTreeView = GUICtrlCreateTreeView(10, 10, 200, 150, -1, $WS_EX_CLIENTEDGE)

$TreeViewItem1 = GUICtrlCreateTreeViewItem("All users", $iTreeView)
$TreeViewSubItem1 = GUICtrlCreateTreeViewItem("ITEM1", $TreeViewItem1)
$Menu1 = GUICtrlCreateContextMenu($TreeViewSubItem1)
$MenuItem1 = GUICtrlCreateMenuItem("Item 1 context menu", $Menu1)

$TreeViewItem2 = GUICtrlCreateTreeViewItem("Friends", $iTreeView)
$TreeViewSubItem2 = GUICtrlCreateTreeViewItem("ITEM2", $TreeViewItem2)
$Menu2 = GUICtrlCreateContextMenu($TreeViewSubItem2)
$MenuItem2 = GUICtrlCreateMenuItem("Item 2 context menu", $Menu2)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $MenuItem1
        MsgBox(0, "", "Item 1 context menu")
    Case $MenuItem2
        MsgBox(0, "", "Item 2 context menu")
    EndSwitch
WEnd

:P

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thx for your scripts :D

Privet, slushai script prostoi i dostupnii, toka eshio odin voprosik a esli tam dopustim mnogo etih Itemov kak na risunke, neujeli dlia kajdoi otdelinoe menu sozdavati ? a nelizia dlia vsei gruppi Friends i vseh poditemov sozdati 1 menu a dlia all users drugoe prosto tyt ispolizuetsa zaputanii mehanizm postroeniia treeitemov [[ vot naprimer: $treeItem[$x][0]=GUICtrlCreateTreeViewItem($NICK, $TreeView1_0) ]]...

This will help to create perfect menus for my Messanger :P

post-22665-1200829838_thumb.png

Edited by Enforcer

[RU] Zone

Share this post


Link to post
Share on other sites

Thx for your scripts :D

Privet, slushai script prostoi i dostupnii, toka eshio odin voprosik a esli tam dopustim mnogo etih Itemov kak na risunke, neujeli dlia kajdoi otdelinoe menu sozdavati ? a nelizia dlia vsei gruppi Friends i vseh poditemov sozdati 1 menu a dlia all users drugoe prosto tyt ispolizuetsa zaputanii mehanizm postroeniia treeitemov [[ vot naprimer: $treeItem[$x][0]=GUICtrlCreateTreeViewItem($NICK, $TreeView1_0) ]]...

This will help to create perfect menus for my Messanger :P

Privet! Two example:

;Example 1

#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

Global $TreeItems[11][2]
$TreeItems[0][0] = 10

$hGui = GUICreate("TreeView context menu", 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

$iTreeView = GUICtrlCreateTreeView(10, 10, 280, 180, -1, $WS_EX_CLIENTEDGE)

$TreeViewItem1 = GUICtrlCreateTreeViewItem("All users", $iTreeView)

For $i = 1 To $TreeItems[0][0]
    $TreeItems[$i][0] = GUICtrlCreateTreeViewItem("NICK", $TreeViewItem1)
    $NickMenu = GUICtrlCreateContextMenu($TreeItems[$i][0])
    GUICtrlCreateMenuItem("Nick", $NickMenu)
    GUICtrlSetOnEvent(-1, "MenuSelect")
    $TreeItems[$i][1] = GUICtrlCreateTreeViewItem("UIN", $TreeViewItem1)
    $UinMenu = GUICtrlCreateContextMenu($TreeItems[$i][1])
    GUICtrlCreateMenuItem("UIN", $UinMenu)
    GUICtrlSetOnEvent(-1, "MenuSelect")
Next

GUISetState()

While 1
    Sleep(100)
WEnd

Func Quit()
    Exit
EndFunc

Func MenuSelect()
    ConsoleWrite("@@ (6) : MenuItem selected" & @CRLF)
EndFuncoÝ÷ Ù«­¢+ØíáµÁ±È((¥¹±Õ±ÐíÕ¥
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíÕ¥QÉY¥Ü¹ÔÌÐì(¥¹±Õ±ÐíÕ¥5¹Ô¹ÔÌÐì()=ÁÐ ÅÕ½Ðí5½ÕÍ
½½É5½ÅÕ½Ðì°È¤()±½°¹Õ´ÀÌØí¥5¹ÕMÑÉÐôÄÀÀÀ°ÀÌØí¥5¹ÕMѽÀ°ÀÌØí¥5¹Õ±Ñ()±½°ÀÌØíQÉ%ѵÍlÙulÉt(ÀÌØíQÉ%ѵÍlÁulÁtôÔ((ÀÌØí¡Õ¤ôU%
ÉÑ ÅÕ½ÐíQÉY¥Ü½¹Ñáе¹ÔÅÕ½Ðì°ÌÀÀ°ÈÀÀ¤((ÀÌØí¡QÉY¥Üô}U%
ÑɱQÉY¥Ý}
ÉÑ ÀÌØí¡Õ¤°ÄÀ°ÄÀ°ÈàÀ°ÄàÀ°´Ä°ÀÌØí]M}a}
1%9Q¤((ÀÌØí¡%Ñ´ô}U%
ÑɱQÉY¥Ý} ÀÌØí¡QÉY¥Ü°À°ÅÕ½Ðí±°ÕÍÉÌÅÕ½Ðì¤()½ÈÀÌØí¤ôÄQ¼ÀÌØíQÉ%ѵÍlÁulÁt($ÀÌØíQÉ%ѵÍlÀÌØí¥ulÁtô}U%
ÑɱQÉY¥Ý}
¡¥± ÀÌØí¡QÉY¥Ü°ÀÌØí¡%Ñ´°ÅÕ½Ðí9%
,ÅÕ½ÐìµÀìÀÌØí¤¤($ÀÌØíQÉ%ѵÍlÀÌØí¥ulÅtô}U%
ÑɱQÉY¥Ý}
¡¥± ÀÌØí¡QÉY¥Ü°ÀÌØí¡%Ñ´°ÅÕ½ÐíU%8ÅÕ½ÐìµÀìÀÌØí¤¤)9áÐ()U%I¥ÍÑÉ5Í ÀÌØí]5}9=Q%d°ÅÕ½Ðí]5}9=Q%dÅÕ½Ðì¤()U%MÑMÑÑ ¤()]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØíµÍ(%
ÍÀÌØíU%}Y9Q}
1=M($%á¥Ñ1½½À(%¹MÝ¥Ñ )]¹()Õ¹]5}9=Q%d ÀÌØí¡]¹°ÀÌØí¥5Í°ÀÌØí¥ÝAÉ´°ÀÌØí¥±AÉ´¤(%1½°ÀÌØí¡]¹É½´°ÀÌØí¥%ɽ´°ÀÌØí¥
½°ÀÌØíÑ95!H°ÀÌØí¡]¹QÉÙ¥Ü(ÀÌØí¡]¹QÉÙ¥ÜôÀÌØí¡QÉY¥Ü(%9½Ð%Í!]¹ ÀÌØí¡QÉY¥Ü¤Q¡¸ÀÌØí¡]¹QÉÙ¥ÜôU%
ÑɱÑ!¹± ÀÌØí¡QÉY¥Ü¤($(ÀÌØíÑ95!Hô±±MÑÉÕÑ
ÉÑ ÀÌØíÑ95!H°ÀÌØí¥±AÉ´¤(ÀÌØí¡]¹É½´ô!]¹¡±±MÑÉÕÑÑÑ ÀÌØíÑ95!H°ÅÕ½Ðí¡]¹É½´ÅÕ½Ð줤(ÀÌØí¥%ɽ´ô±±MÑÉÕÑÑÑ ÀÌØíÑ95!H°ÅÕ½Ðí%ɽ´ÅÕ½Ðì¤(ÀÌØí¥
½ô±±MÑÉÕÑÑÑ ÀÌØíÑ95!H°ÅÕ½Ðí
½ÅÕ½Ðì¤((%MÝ¥Ñ ÀÌØí¡]¹É½´(%
ÍÀÌØí¡]¹QÉÙ¥Ü($%MÝ¥Ñ ÀÌØí¥
½($%
ÍÀÌØí95}I
1%
,($$%QÉY¥Ý}I
±¥¬ ¤($%¹MÝ¥Ñ (%¹MÝ¥Ñ )¹Õ¹()Õ¹QÉY¥Ý}I
±¥¬ ¤(1½°ÀÌØí!¥Ð°ÀÌØí5½ÕÍA½Ì°ÀÌØí¡5¹Ô($($ÀÌØí5½ÕÍA½Ìô5½ÕÍÑA½Ì ¤($ÀÌØí!¥Ðô}U%
ÑɱQÉY¥Ý}!¥ÑQÍÑ%Ñ´ ÀÌØí¡QÉY¥Ü°ÀÌØí5½ÕÍA½ÍlÁt°ÀÌØí5½ÕÍA½ÍlÅt¤(% ÀÌØí!¥Ð±ÐìÐìÀ¤Q¡¸((ÀÌØí¡5¹Ôô}U%
Ñɱ5¹Õ}
ÉÑA½ÁÕÀ ¤(}U%
Ñɱ5¹Õ}5¹Õ%Ñ´ ÀÌØí¡5¹Ô°ÅÕ½ÐíMÑÉÐÅÕ½Ðì°ÀÌØí¥5¹ÕMÑÉФ(}U%
Ñɱ5¹Õ}5¹Õ%Ñ´ ÀÌØí¡5¹Ô°ÅÕ½ÐíMѽÀÅÕ½Ðì°ÀÌØí¥5¹ÕMѽÀ¤(}U%
Ñɱ5¹Õ}5¹Õ%Ñ´ ÀÌØí¡5¹Ô°ÅÕ½Ðí±ÑÅÕ½Ðì°ÀÌØí¥5¹Õ±Ñ¤((MÝ¥Ñ }U%
Ñɱ5¹Õ}QÉ­A½ÁÕÁ5¹Ô ÀÌØí¡5¹Ô°ÀÌØí¡QÉY¥Ü°´Ä°´Ä°Ä°Ä°È¤(
ÍÀÌØí¥5¹ÕMÑÉÐ(
½¹Í½±]É¥Ñ ÅÕ½ÐíMÑÉÐÅÕ½ÐìµÀì
I1¤(
ÍÀÌØí¥5¹ÕMѽÀ(
½¹Í½±]É¥Ñ ÅÕ½ÐíMѽÀÅÕ½Ðì¤($$%
ÍÀÌØí¥5¹Õ±Ñ($$$%
½¹Í½±]É¥Ñ ÅÕ½ÐíMѽÀÅÕ½Ðì¤(¹MÝ¥Ñ (}U%
Ñɱ5¹Õ}ÍÑɽå5¹Ô ÀÌØí¡5¹Ô¤(¹%)¹Õ¹ìôôÐí1¥ÍÑY¥Ý}I
±¥¬

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