Jump to content

disable entire tabsheet


Recommended Posts

Hello,

i have form that include 3 tabsheet ,i am looking for a way disabling entire of only one of the three tab sheet when i checking a checkbox.

please advice

thanks

Edited by tbaror
Link to comment
Share on other sites

Hello,

i have form that include 3 tabsheet ,i am looking for a way disabling entire of only one of the three tab sheet when i checking a checkbox.

please advice

thanks

; modified From Example of TAB in TAB ctrl by aec in AutoIt post

EDIT: This code will disable the components on the tab but the tab can still be selected. If that is not what you meant then gafrost's post which follows is the solution.

#include <GUIConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

;This window has 2 ok/enable-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$Enable_button  = GUICtrlCreateCheckbox("Disable Tab 2",150,220,100,20)

; Create the first child window that is implemented into the main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab      = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("A")
$child12tab     = GUICtrlCreateTabItem("B")
GUICtrlCreateTabItem("")

GUISetState()

; Create the second child window that is implemented into the main GUI
$child2         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$listview2      = GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Tab 1")
$child2tab      = GUICtrlCreateTabItem("Tab 2")
GUICtrlCreateTabItem("")

GUISetState()
$HideShow = $GUI_HIDE + $GUI_SHOW
$tab2state = true

GUIRegisterMsg($WM_NOTIFY,"WM_Notify_Events")

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Enable_button
            $tab2state = GUICtrlRead($Enable_button) = $GUI_UNCHECKED
            If $tab2state Then
              GUISetState(@SW_ENABLE,$child2)
          Else
               GUISetState(@SW_DISABLE ,$child2)
              EndIf
                  
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
          
                Case 1
                  GUISetState(@SW_HIDE,$child1)
                  GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd



Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
   ;#forceref $hWndGUI, $MsgID
    Local $tagNMHDR, $event
    Local Const $NM_RETURN = $NM_FIRST - 4
    Local Const $NM_RCLICK = -5
    Local Const $TCN_FIRST = -550
    Local Const $TCN_SELCHANGING = $TCN_FIRST-2
    Local $toTab
    Local $Debugit = True

    Switch $wParam
        Case $Main_Tab       
            $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $TCN_SELCHANGING
                    $Event_Code = $event
                    $toTab = DllStructGetData($tagNMHDR, 2)
                    If $DebugIt Then ConsoleWrite("-->$TCN_SELCHANGING to " & $toTab & @LF)
            EndSwitch
        EndSwitch   
$tagNMHDR = 0
EndFunc;==>WM_Notify_Events
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...