Jump to content

IPAddress Control on tabsheet, show/hide problem


rodent1
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

rodent1,

First, when you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. ;)

You need to read the Help file about tabs - you get a message from the main Tab control and then you need to use GUICtrlRead to get the selected tabitem. I also recommend you read the Tabs tutorial in the Wiki to see how to manage UDF created controls. You will end up with something like this: :)

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

$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)
$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("")

; As this is a UDF created control you nee dnot cretae it in the tab structure
$IPAddressBox = _GUICtrlIpAddress_Create($frmSelPrinter, 296, 96, 249, 25)
_GUICtrlIpAddress_Set($IPAddressBox, "0.0.0.0")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Tab1 ; Look for the main tab
            Switch GUICtrlRead($Tab1) ; And then read the selected tab
                Case 0
                    ControlHide($frmSelPrinter, "", $IPAddressBox) ; ControlShow/Hide is what you need here
                Case 1
                    ControlShow($frmSelPrinter, "", $IPAddressBox)
            EndSwitch
    EndSwitch
WEnd

All clear? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

×
×
  • Create New...