Sign in to follow this  
Followers 0
johnmcloud

[SOLVED] TabSheet on click?

7 posts in this topic

#1 ·  Posted (edited)

Hi guys, i have a question about TabSheet:

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

$GUI = GUICreate("Test GUI", 413, 273, 210, 151)
GUISetIcon("", -1)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $TabSheet2
   MsgBox(0,0,"Test")
EndSwitch
WEnd

I want to set, when user click on TabSheet2, a event, in this case i have make a simply MsgBox. But case not work. How to set an event when click on TabSheet2?

Thanks for support :)

EDIT. A second and last question. Is see now Ctrl+TAB don't change the Tab position like windows. How to set it? Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites



johnmcloud,

You need to look for the entire tab control being actioned and then use GUICtrlRead to find the active tab: ;)

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

$GUI = GUICreate("Test GUI", 413, 273, 210, 151)
GUISetIcon("", -1)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $PageControl1
            Switch GUICtrlRead($PageControl1)
                Case 1 ; Remember tabs start at 0
                    MsgBox(0, 0, "Test")
            EndSwitch
    EndSwitch
WEnd

In your second question, do you mean that you want Ctrl-TAB to move the focus from one tab to another? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba,

Your never use Ctrl+TAB in windows for move TABs? Or Explorer/browser to move from a page to another? That :)

Share this post


Link to post
Share on other sites

johnmcloud,

No, I do not. :)

But this will let you do it with your tabs: ;)

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

Global $aTab[3]

$GUI = GUICreate("Test GUI", 413, 273, 210, 151)
GUISetIcon("", -1)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
$aTab[0] = GUICtrlCreateTabItem("TabSheet1")
$aTab[1] = GUICtrlCreateTabItem("TabSheet2")
$aTab[2] = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")

$cDummy = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)

Local $aAccelKeys[1][2] = [["^{TAB}", $cDummy]]
GUISetAccelerators($aAccelKeys)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $PageControl1
            Switch GUICtrlRead($PageControl1)
                Case 1
                    MsgBox(0, 0, "Test")
            EndSwitch
        Case $cDummy
            ; Get index of next tab to focus - Mod resets to 0 instead of 3
            $iIndex = Mod(GUICtrlRead($PageControl1) + 1, 3)
            GUICtrlSetState($atab[$iIndex], $GUI_SHOW)
    EndSwitch
WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks, work, but has only a little limitation, when Tab2 is focused don't show the MsgBox, you can resolve this? I really apprecciate your help, thanks :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

johnmcloud,

Picky! :)

#include <guiconstantsex.au3>
#include <tabconstants.au3>
#include <windowsconstants.au3>

Global $aTab[3]

$GUI = GUICreate("Test GUI", 413, 273, 210, 151)
GUISetIcon("", -1)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
$aTab[0] = GUICtrlCreateTabItem("TabSheet1")
$aTab[1] = GUICtrlCreateTabItem("TabSheet2")
$aTab[2] = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")

$cDummy = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)

Local $aAccelKeys[1][2] = [["^{TAB}", $cDummy]]
GUISetAccelerators($aAccelKeys)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cDummy
            ; Get index of next tab to focus - Mod resets to 0 instead of 3
            $iIndex = Mod(GUICtrlRead($PageControl1) + 1, 3)
            GUICtrlSetState($atab[$iIndex], $GUI_SHOW)
            ;If $iIndex = 1 Then ContinueCase
            ContinueCase
        Case $PageControl1
            Switch GUICtrlRead($PageControl1)
                Case 1
                    MsgBox(0, 0, "Test")
            EndSwitch

    EndSwitch
WEnd

M23

Edit: You do not need the If before the ContinueCase as the Switch does that for you. ;)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Perfect, i'm not picky lol, the event copy some text form inputbox from tab1 to tab2 and some from tab2 to tab3, so if i'm using shortcut i need to copy the value :)

Have a nice day,

John

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

  • Similar Content

    • rodent1
      By rodent1
      This is koda generated code. There is one commented line, ";_GUICtrlIpAddress_ShowHide($IPAddressBox, @SW_HIDE)". If it is commented out, the control appears on all tabs, whatever my tab selection. It it's not commented out, _GUICtrlIpAddress_ShowHide($IPAddressBox, @SW_SHOW) in  the $TabSheet2 case does not make it reappear. I suppose it is hidden behind the tab. Is there a way to make this work? The code:

      #include
      #include
      #include
      #include
      #include
      #include
      #include
      #Region ### START Koda GUI section ### Form=
      $frmSelPrinter = GUICreate("X Coon Select Printer", 578, 351, 192, 124)
      $Tab1 = GUICtrlCreateTab(8, 8, 561, 329)
      $TabSheet1 = GUICtrlCreateTabItem("Use Windows Drivers")
      $lbPrinters = GUICtrlCreateList("", 24, 64, 529, 214)
      $Label1 = GUICtrlCreateLabel("Available Windows Drivers :", 24, 40, 136, 17)
      $btnSelectDriver = GUICtrlCreateButton("Select Driver", 24, 288, 137, 33)
      $TabSheet2 = GUICtrlCreateTabItem("use LPR")
      GUICtrlSetState(-1,$GUI_SHOW)
      $rbWinDrv = GUICtrlCreateRadio("Send jobs through Windows driver", 24, 48, 201, 17)
      $Radio1 = GUICtrlCreateRadio("Send jobs to an IP address", 288, 48, 201, 17)
      $lbWinDrivers = GUICtrlCreateList("", 24, 96, 241, 175)
      $IPAddressBox = _GUICtrlIpAddress_Create($frmSelPrinter, 296, 96, 249, 25)
      _GUICtrlIpAddress_Set($IPAddressBox, "0.0.0.0")
      ;_GUICtrlIpAddress_ShowHide($IPAddressBox, @SW_HIDE)
      $Label2 = GUICtrlCreateLabel("IP Address :", 288, 72, 61, 17)
      $Label3 = GUICtrlCreateLabel("Available Windows Drivers :", 24, 72, 136, 17)
      $btnSelDriver = GUICtrlCreateButton("Select Driver", 24, 296, 129, 25)
      $Button1 = GUICtrlCreateButton("Accept IP Address", 432, 296, 113, 25)
      GUICtrlCreateTabItem("")
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###

      While 1
          $nMsg = GUIGetMsg()
          Switch $nMsg
              Case $GUI_EVENT_CLOSE
                  Exit
              case $TabSheet1 ;case added outside of koda to allow switching tabs
                  _GUICtrlIpAddress_ShowHide($IPAddressBox, @SW_HIDE)
              case $TabSheet2 ;case added outside of koda to allow switching tabs
                  _GUICtrlIpAddress_ShowHide($IPAddressBox, @SW_SHOW)
          EndSwitch
      WEnd