Sign in to follow this  
Followers 0
rodent1

IPAddress Control on tabsheet, show/hide problem

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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


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

All clear! Works like a charm! Thanks Melba23

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

    • dreivilo47
      By dreivilo47
      I have created a form in Koda.
      When I want to see a form preview, I choose "Tools", "Run Form".
      But in place of a form preview I see a file opened in Notepad (test.au3) with code.
      What do I wrong?
    • dascondor
      By dascondor
      I  need to has Opt(GUISetOnEvent,-1) available in my script, but since I'm using koda designer it uses GUIgetmessage is there any work around for this. I'm pretty new to this stuff so any help is great appreciated.
      Any Thoughts?
       
    • TheSaint
      By TheSaint
      As many of you may not be aware, of much about AutoIt's humble beginnings, and aspects related to the first GUI version of AutoIt, I thought it might be nice to create a historical reference here for all the many GUI creators that have been created by various people over the years.
      NOTE - While one could argue, that this topic might be better placed in one of the Chat forums, I would argue, that it links to heaps of good code. While much may be redundant in that code, it is still interesting and forms a great perspective. Many are bound to find useful elements at the very least.
      Koda, is no doubt the most well-known GUI creator now, but there was a time, when CyberSlug's legendary GUIBuilder (first known as AutoBuilder) ruled the roost, and AutoIt coder's saw it as a Godsend. AutoIt coding was much simpler back then of course.
      Below, will be a timeline, of any AutoIt GUI creators listed in forum pages. It will be added to by myself as I find them or as others here find them and place a link in a subsequent post ... PLEASE HELP! Comments welcome too.
      (Also note, that this is also intended to include updates, branches etc by others)
      Apr 20 2004 - AutoBuilder by CyberSlug.
      Sep 27 2004 - An interesting topic, where CyberSlug talks about the future of AutoBuilder (etc) and renaming to GUIBuilder and you see the first mentions and links to updates by others (including myself & livewire).
      Nov 05 2004 - A topic where lookfar is working on a SciTE replacement, talks about starting a Form Designer.
      Aug 10 2005 - GuiBuilder first update by TheSaint.
      Sep 26 2005 - GUIBuilder updates by livewire (he also talks about transferring his efforts to Koda).
      Nov 02 2005 - KODA FormDesigner v1.3 by lookfar
      Nov 03 2005 - Seemingly interesting topic about forms by tonedeaf
      Dec 26 2005 - AutoIt Studio(beta) by BillLuvsU
      Jan 09 2006 - AutoBuilder update (or branch) by _^__darkbytez (livewire also posts).
      Feb 19 2006 - Koda v1.5 by lookfar
      Sep 07 2006 - Koda v1.7.3.0 by Lazycat
      Jan 07 2007 - Form/GUI Builder by FlintBrenick
      Jun 10 2007 - Gorganizer by _Kurt (more of an assister than actual GUI maker)
      Jun 27 2007 - Basic GUI Designer by Mast3rpyr0
      May 03 2008 - Autoit Programmer's Desktop (APD) by Ealric
      Jul 11 2008 - Gui Designer by Alek
      Aug 11 2008 - Gorganizer update by _Kurt
      Jun 19 2009 - Easy GUI by Mat
      Aug 13 2009 - GUI Script Creator by Pandemic (not sure this qualifies, but it made me think of templates)
      Aug 16 2010 - Creation Gui by AZJIO
      Jan 22 2012 - ISN AutoIt Studio by ISI360 (includes ISN Form Studio 2, a GUI editor)
      Mar 19 2012 - Arduino GUI Programmer by nikosliapis (creates a specific type of GUI)
      Aug 01 2012 - GuiBuilder Resurrected update/branch to GUIBuilder by baroquebob
      Dec 01 2012 - Form Builder beta (v1.0.6) by BuckMaster
      Jan 12 2015 - GUIBuilderNxt update by jaberwacky of GUIBuilder v0.8 (as a new prototype, modified to work with latest AutoIt) (not a update to the Resurrected version)
      Aug 12 2016 - The GuiBuilder Return by DFerrato as an update to GUIBuilder,
      Jan 17 2017 - GUIBuilder Project by TheSaint (a work in progress based on CyberSlug's original ... and later versions, updated by Roy, TheSaint & others).
      There are a significant number of creators/designers that have been started and never completed.
      +++++ STILL UNDER CONSTRUCTION +++++
      P.S. Well that's it from me tonight. I know of at least one other major creator, but cannot recall it's name or the name of the coder, though I think it starts with 'L'. Bound to be a few I've missed, and some I cannot seem to find their first appearance here (Koda, Form Builder, etc), but there may be an obvious reason for that. Will probably rely on feedback from others now that I've got the ball rolling.
      NOTE - If anyone wants to discuss any of these programs above or give some background history, then by all means do so. I will cross-reference (link to) any important comments.
    • Masum
      By Masum
      Hi all,
      Can the default Koda icon for forms be changed? If so, how?
      Thanks
    • Morthawt
      By Morthawt
      I have a program I made long ago for something but I never saved the koda file so it would make it a complete pain for me to visually tweak anything because as far as I am aware, I would have to design an entirely new GUI.
      Would it be possible for you guys at AutoIt to add functionality to Koda so that you can take an existing GUI section, with while loop and cases and all and then koda would literally build it ready for tweaking and where existing things still exist and have been tweaked, it would tweak such details and keep all the existing case information and added formatting things that were manually tweaked etc?
      This would be really amazing and I feel that other people would benefit from it. I can't be the only person who makes a GUI, doesn't save it and then has no problems making minor tweaks in-code but struggles like hell to go rearranging things perfectly. That is where using a GUI (koda) to make and arrange a GUI you are making, makes everything easy and pleasure to deal with.
      tldr;
      Example:
      A friend gives me his code and wants help. The GUI is just a mess, but trying to do all the alignment and positioning all by digits in code would be a pain. I cannot just hallucinate where everything is based on pixel locations and sizes. So I would take the entire GUI chunk of code, all the form/controls/formatting functions/while loop/switch/case in it's entirety and paste it into an area of Koda and press a button. Koda would then build the GUI on the screen, placing all the controls and formatting them with the instructions that may have been added and keeps the case information as-is. Then when you make your alterations in Koda, you go to export it and it makes an entirely new export that re-makes (from scratch as if you had made this GUI from scratch) all the code for controls, size, placement etc and then also adds all the existing case code back as part of the code you then send (or manually copy/paste as I do) to Scite editor.
      Is there any chance this could be implemented? I think this could help a lot of people with their own scripts and others'.