Jump to content

GUIOnEventMode w/tab controls?

Recommended Posts

I want to fire a function when a tab control is clicked, I tryed it the same way as when I do buttons. Should this work and I am just being daft....

$tab2=GUICtrlCreateTabitem("Weekly Build")
GUICtrlSetOnEvent($tab2, "showWeekly")
GUICtrlCreateLabel("This is the weekly build tab", 5,35,150,20)
Link to post
Share on other sites

Like info:

At the moment, this message(a click on a tabitem) isn't passed like an event in AutoIt.

If you can see, this event doesn't works using the MessageLoop mode too.

Ok I can accept that, is anyone aware of a work around? I posted a rephrase of this question in the GUI forum so answer there if you are so inclined.

Link to post
Share on other sites

silly question, but why do you need to have something like that? Are you looking to change colors on the tabs, (That would be a kewl thing to know), or looking to do something like run a web page on the clicking of the tab? I'm just brainstorming here, but you might want to check out the beta to see it the function is added there.

Link to post
Share on other sites

beta help.... it can do it

its not " set on event"... but maybe you can code it to be

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status, $current, $button

GUICreate("Tab Get Current Selection", 300, 200); will create a dialog box that when displayed is centered

GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem(""); end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem(""); end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW); will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem(""); end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem(""); end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem(""); end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUICtrlSetData($Status, "Current Selection: " & _GUICtrlTabGetCurSel ($tab))

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
        Case $msg = $tab
            GUICtrlSetData($Status, "Current Selection: " & _GUICtrlTabGetCurSel ($tab))


Edited by Valuater


Link to post
Share on other sites

I found this.... and looking at another way also

_________________________________________Initial Set Up_____________________________

AutoItSetOption ( "SendKeyDelay", '.01' )
AutoItSetOption ( "WinTitleMatchMode", 2 )

#include <GUIConstants.au3>
;#include <_IsPressed.au3>
#include <misc.au3>

Opt("GuiOnEventMode", 1)

;_________________________________________MAIN GUI And Buttons_______________________
$GuiWidth = 100
$GuiHeight = 500
$xPos = (@DesktopWidth-105)
$yPos = (@DesktopHeight - $GuiHeight) / 2

$Gui = GUICreate("GuiRight", 100, 500,$xpos, $yPos, $WS_POPUP,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)
;GUISetBkColor (0)

$ButtonA = GUICtrlCreateButton ( "ButtonA", 15, 20 ,75 ,15)
GUICtrlSetOnEvent($ButtonA, "ButtonA_Pressed")

$ButtonB = GUICtrlCreateButton ( "ButtonB", 15, 40 ,75 ,15)
GUICtrlSetOnEvent($ButtonB, "ButtonB_Pressed")

$ButtonC = GUICtrlCreateButton ( "Terminate", 15, 460 ,75 ,15)
GUICtrlSetOnEvent($ButtonC, "Terminate")

;________________________________"More" Button & Right Click MoreButton___________________________

$MoreButton = GUICtrlCreateButton ( "More", 15, 480 ,75 ,15)
GUICtrlSetOnEvent($MoreButton, "More")

$bcontext = GUICtrlCreateContextMenu($MoreButton)
$bexit = GUICtrlCreateMenuitem("Exit",$bcontext)
GUICtrlSetOnEvent(-1, "Terminate")

$b_new_to_me = GUICtrlCreateMenuitem("New to me",$bcontext)
GUICtrlSetOnEvent(-1, "New_to_me")

;set this to hide if you want



;______________________________LOOP Mouse click trapper(01=rt 02=rt 04=mid)__________

While 1
;$msg = GUIGetMsg()

$i = MouseGetPos()
If _IsPressed('04') = 1 Then Call ("Calig")
If _IsPressed('02') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Show_Gui") 
If _IsPressed('01') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Bang")
If _IsPressed('01') = 1 AND $i[0] < @DesktopWidth -100 Then GUISetState(@SW_HIDE, "GuiRight") 


;______________________________Button Functions____________________________________________

Func ButtonA_Pressed()
MsgBox(4096,"control", "Button_A pressed") 
GUISetState(@SW_HIDE, "GuiRight")

Func ButtonB_Pressed()
MsgBox(4096,"control", "Button_B pressed") 
GUISetState(@SW_HIDE, "GuiRight")
GUISetState(@SW_HIDE, "More")

Func Terminate() 
Exit 0 

Func More() 
MsgBox(4096,"control", "Button_Go pressed")
GUISetState(@SW_HIDE, "GuiRight")
GUISetState(@SW_HIDE, "More")

Func Show_Gui() 
Sleep (200) 
Send ("{ESC}")
GUISetState(@SW_SHOW, "GuiRight") 

;________________________________Next Left Click Functions________________________________

Func Bang()
MsgBox(4096,"control", "Bang! Bang! Bang!") 

Func Calig()
; dont know what this one does ????
MsgBox(4096,"control", "Calig! Calig! Calig!") 

Func New_to_me()
MsgBox(4096,"control", "This right click menu inside of a button is new to me  "& @CRLF & @CRLF  & "Bang! Bang! Bang!") 

;_______________________________________Hotkey Functions___________________________________

;_______________________________________________The End______________________________________


it works too!


Edited by Valuater


Link to post
Share on other sites

heres another way to do it

; a set on event still has a while loop that can be utilized


While 1
    If $a[0] >= ???? And  $a[0] <= ???? And  $a[1] >= ???? And  $a[1] <= ???? Then; the x and y coord of your tab (left/right and top/bottom)
        Call("the Function")

i am sure there are many ways



Link to post
Share on other sites

ok last one

from help

GUIEventCompatibilityMode Change special event behavior or GUI function return values.

0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize.

1 = suppress windows behavior on minimize, restoreor maximize click button or window resize. Just send the notification.

2 = GUICtrlRead of a tab control return controlID instead index of the tab.

These modes can be combine if you want both.

not EXACTlY sure what that means... but i think its what your looking for



Link to post
Share on other sites

Here is the working code:

$msg = GUIGetMsg()
        Case $msg = $tabs
            $CURRENT_TAB = _GUICtrlTabGetCurSel ($tabs)             
                Case $CURRENT_TAB = 0
                Case $CURRENT_TAB = 1
                Case $CURRENT_TAB = 2                   

bleh too bad the code formating sucks...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...