Sign in to follow this  
Followers 0
Hooch

GUIOnEventMode w/tab controls?

15 posts in this topic

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)

Share this post


Link to post
Share on other sites



Is this a stupid question or nobody knows? Yes I looked at the help file. Yes I searched the forums.

Share this post


Link to post
Share on other sites

Is this a stupid question or nobody knows? Yes I looked at the help file. Yes I searched the forums.

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.

Share this post


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.

Share this post


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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

GUISetBkColor(0x00E0FFFF)
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))

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

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

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Ahhh thanks Valuater, I think I can use that. Now that I have gotten used to oneventMode I hate to go back to msg, but hey, we do what we must.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

_________________________________________Initial Set Up_____________________________

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

;#NoTrayIcon 
#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
$ButtonA = GUICtrlCreateButton ( "ButtonA", 15, 20 ,75 ,15)
GUICtrlSetOnEvent($ButtonA, "ButtonA_Pressed")

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


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

;________________________________"More" Button & Right Click MoreButton___________________________

;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
GUISetState()

;_________________________________________Hotkeys_____________________________________

;_____________________________________________________________________________________

;______________________________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") 

Wend
;__________________________________________________________________________________________

;______________________________Button Functions____________________________________________

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

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

Func Terminate() 
Exit 0 
EndFunc

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

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

;________________________________Next Left Click Functions________________________________

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

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

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

;_______________________________________Hotkey Functions___________________________________



;_______________________________________________The End______________________________________

GUIDelete()

it works too!

8)

Edited by Valuater

NEWHeader1.png

Share this post


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

;example

While 1
    
    $a=GUIGetCursorInfo()
    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")
    EndIf

i am sure there are many ways

8)


NEWHeader1.png

Share this post


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

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I am going to use:

_GUICtrlTabGetCurSel

Determines the currently selected tab in a tab control.

This should give me exactly what I want, got to get some work done before I play with it though :;)

Share this post


Link to post
Share on other sites

Here is the working code:

$msg = GUIGetMsg()
    Select
        Case $msg = $tabs
            $CURRENT_TAB = _GUICtrlTabGetCurSel ($tabs)             
            Select
                Case $CURRENT_TAB = 0
                    showDaily()
                Case $CURRENT_TAB = 1
                    showWeekly()
                Case $CURRENT_TAB = 2                   
                    showDeploy()
            EndSelect
    EndSelect

bleh too bad the code formating sucks...

Share this post


Link to post
Share on other sites

qafrost posted the same concept but with oneventmode. Very tasty, thanks guys!

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