Jump to content
Sign in to follow this  
Madza91

Select Tab item on right click on it...

Recommended Posts

Madza91

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) :)

Share this post


Link to post
Share on other sites
billthecreator

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
Madza91

Rasim, so perfect, thx :P


[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) :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.