Jump to content

Select Tab item on right click on it...


 Share

Recommended Posts

Hello

How to made this: on right click on Tab Item to be focused that item... ?

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>

$gui = GUICreate("My GUI Context Menu", 400, 300)
$Tab1 = GUICtrlCreateTab(100, 10, 129, 200)
$buttoncontext2 = GUICtrlCreateContextMenu($Tab1)
$buttonitem = GUICtrlCreateMenuItem("Close Tab", $buttoncontext2)
$item1 = GUICtrlCreateTabItem("Tab 1")
$item2 = GUICtrlCreateTabItem("Tab 2")
GUICtrlCreateTabItem("")

GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

try this... [not tested]

If ControlClick ( "My GUI Context Menu", "", $item2,"right") = 1 then
GUICtrlSetState($item2, $GUI_SHOW)
endif
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

n3nE

How to made this: on right click on Tab Item to be focused that item... ?

Try this:

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

$gui = GUICreate("My GUI Context Menu", 400, 300)

$Tab1 = GUICtrlCreateTab(100, 10, 129, 200)

$buttoncontext2 = GUICtrlCreateContextMenu($Tab1)

$buttonitem = GUICtrlCreateMenuItem("Close Tab", $buttoncontext2)

$item1 = GUICtrlCreateTabItem("Tab 1")

$item2 = GUICtrlCreateTabItem("Tab 2")

GUICtrlCreateTabItem("")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

GUIDelete()

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $iIDFrom, $iCode
    
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $iIDFrom
        Case $Tab1
            Switch $iCode
                Case $NM_RCLICK
                    $tPOINT = _WinAPI_GetMousePos(True, $gui)
                    Local $iX = DllStructGetData($tPOINT, "X")
                    Local $iY = DllStructGetData($tPOINT, "Y")
                    
                    Local $aPos = ControlGetPos($gui, "", $Tab1)
                    
                    Local $aHit = _GUICtrlTab_HitTest($Tab1, $iX - $aPos[0], $iY - $aPos[1])
                    If $aHit[0] <> -1 Then _GUICtrlTab_SetCurSel($Tab1, $aHit[0])
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
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...