Jump to content

Context Menu and Tab Items


dcop
 Share

Recommended Posts

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1")
$Tab1 = GUICtrlCreateTab(144, 88, 193, 97)
$item1 = GUICtrlCreateTabItem("1")
$men = GUICtrlCreateContextMenu ($item1)
$menItem = GUICtrlCreateMenuitem("test",$men)
$item2 = GUICtrlCreateTabItem("2")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
Sleep(250)
WEnd

Won't Context Menus work with Tab Items? I searched the help real good, honest! :)

Link to comment
Share on other sites

  • 2 weeks later...

you are absolutly right it works this way

#include <GUIConstants.au3>
GUICreate("TEST", 200, 110)

GUICtrlCreateTab (10,10,180,90)
$tab1 = GUICtrlCreateTabItem ("tab - 1")
$1Context = GUICtrlCreateContextMenu ()
$1context_1 = GUICtrlCreateMenuItem ("Context item -1",$1Context)
GUICtrlCreateMenuItem ("",$1Context)
$1context_2 = GUICtrlCreateMenuItem ("Context item -2",$1Context)
$tab2 = GUICtrlCreateTabItem ("tab - 2")

GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEndoÝ÷ Ù»­üÁ©ív'ßz·§´*'µìm1éî~ÞiÈmi¸­v¬mÂä{¦¦WºÚ"µÍÚ[ÛYH   ÑÕRPÛÛÝ[Ë]LÉÝÂÕRPÜX]J    ][ÝÕTÕ   ][ÝËLL
BÕRPÝÜX]UX
LLNL
BÌÍÝXHHÕRPÝÜX]UX][H
    ][ÝÝXHI][ÝÊBÌÍÌPÛÛ^HÕRPÝÜX]PÛÛ^Y[H
    ÌÍÝXJBÌÍÌXÛÛ^ÌHHÕRPÝÜX]SY[R][H
    ][ÝÐÛÛ^][HLHHÜXLI][ÝË    ÌÍÌPÛÛ^
BÕRPÝÜX]SY[R][H
    ][ÝÉ][ÝË    ÌÍÌPÛÛ^
BÌÍÌXÛÛ^ÌHÕRPÝÜX]SY[R][H
    ][ÝÐÛÛ^][HLHÜXLI][ÝË ÌÍÌPÛÛ^
BÌÍÝXHÕRPÝÜX]UX][H
    ][ÝÝXH][ÝÊBÌÍÌÛÛ^HÕRPÝÜX]PÛÛ^Y[H
    ÌÍÝXBÌÍÌÛÛ^ÌHHÕRPÝÜX]SY[R][H
    ][ÝÐÛÛ^][HLHHÜXL][ÝË ÌÍÌÛÛ^
BÕRPÝÜX]SY[R][H
    ][ÝÉ][ÝË    ÌÍÌÛÛ^
BÌÍÌÛÛ^ÌHÕRPÝÜX]SY[R][H
    ][ÝÐÛÛ^][HLHÜXL][ÝË  ÌÍÌÛÛ^
BÕRTÙ]Ý]J
BÚ[HB  ÌÍÛÙÈHÕRQÙ]ÙÊ
BY  ÌÍÛÙÈH ÌÍÑÕRWÑUSÐÓÔÑH[^]ÛÜÑ[

we have to ask some old expert about this

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Context menu on a tab only works at the top of the tab item (where the text of the tab is)

Might try something like:

#include <GUIConstants.au3>
GUICreate("TEST", 200, 110)

$2context_1 = -998
$2context_2 = -999

$tab = GUICtrlCreateTab(10, 10, 180, 90)
$tab1 = GUICtrlCreateTabItem("tab - 1")
$1Context = GUICtrlCreateContextMenu($tab)
$1context_1 = GUICtrlCreateMenuItem("Context item -1", $1Context)
$1context_2 = GUICtrlCreateMenuItem("Context item -2", $1Context)
;~ GUICtrlCreateMenuItem ("",$1Context)
$tab2 = GUICtrlCreateTabItem("tab - 2")
GUICtrlSetState($tab1, $GUI_SHOW)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $tab
            _RebuildContextMenu(GUICtrlRead($tab))
        Case $1context_1
            ConsoleWrite("$1context_1" & @LF)
        Case $1context_2
            ConsoleWrite("$1context_2" & @LF)
        Case $2context_1
            ConsoleWrite("$2context_1" & @LF)
        Case $2context_2
            ConsoleWrite("$2context_1" & @LF)
    EndSwitch
WEnd

Func _RebuildContextMenu($tab_item)
    Switch $tab_item
        Case 0
            $1context_1 = GUICtrlCreateMenuItem("Context item -1", $1Context)
            $1context_2 = GUICtrlCreateMenuItem("Context item -2", $1Context)
            GUICtrlDelete($2context_1)
            GUICtrlDelete($2context_2)
            $2context_1 = -998
            $2context_2 = -999
        Case 1
            $2context_1 = GUICtrlCreateMenuItem("Context item -3", $1Context)
            $2context_2 = GUICtrlCreateMenuItem("Context item -4", $1Context)
            GUICtrlDelete($1context_1)
            GUICtrlDelete($1context_2)
            $1context_1 = -998
            $1context_2 = -999
    EndSwitch
EndFunc   ;==>_RebuildContextMenu

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

JUST A LITTLE INSPIRED

now I need Correction for this :

#include <GUIConstants.au3>
GUICreate("TEST", 200, 140)

$tab = GUICtrlCreateTab (10,10,180,90)
GUICtrlCreateTabItem ("tab - 1")
GUICtrlCreateTabItem ("tab - 2")
GUICtrlCreateTabItem ("")

$context = GUICtrlCreateContextMenu ()

$con_1 = GUICtrlCreateMenuItem ("test-1",$context)
GUICtrlSetState (-1,$GUI_HIDE)
$con_2 = GUICtrlCreateMenuItem ("test-2",$context)
GUICtrlSetState (-1,$GUI_HIDE)
$con_3 = GUICtrlCreateMenuItem ("test-3",$context)
GUICtrlSetState (-1,$GUI_HIDE)
$con_4 = GUICtrlCreateMenuItem ("test-4",$context)
GUICtrlSetState (-1,$GUI_HIDE)

$go = GUICtrlCreateButton ("go",10,110,180,25)

GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $go Then
        MsgBox (-1,"info", GUICtrlRead ($tab))
    EndIf
    If GUICtrlRead ($tab) = 0 Then
        _con1()
    EndIf
    If GUICtrlRead ($tab) = 1 Then
        _con2()
    EndIf
WEnd

Func _con1 ()
    GUICtrlSetState ($con_1,$GUI_HIDE)
    GUICtrlSetState ($con_2,$GUI_HIDE)
    GUICtrlSetState ($con_3,$GUI_SHOW)
    GUICtrlSetState ($con_4,$GUI_SHOW)
EndFunc

Func _con2 ()
    GUICtrlSetState ($con_3,$GUI_HIDE)
    GUICtrlSetState ($con_4,$GUI_HIDE)
    GUICtrlSetState ($con_1,$GUI_SHOW)
    GUICtrlSetState ($con_2,$GUI_SHOW)
EndFunc

it works with OTHER GUICTRL exept menuitem

?????????

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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...