Sign in to follow this  
Followers 0
13lack13lade

Tabs in GUI

9 posts in this topic

#1 ·  Posted (edited)

Hi Guys,

I am wanting to use a simple tab with 2 tabitems, one for 1 set of pictures, one for the other set of pictures...

i have read http://www.autoitscript.com/wiki/Tabs to try and get an idea of how to do it, now i understand i need to 'hide' the images depending on which tab is open however im not sure how to do it correctly using pictures, as the example uses buttons so it is set out differently. and i did give it a crack following the example hiding the pictures the same way as the buttons however it did not work..

Is anyone able to help me simply showing me the correct way to have it coded to hide show depending on what tab im in?

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$DataloadScreen_2 = GUICreate("FCGP Dashboard", 1179, 758, 256, 99)
$Banner = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\banner.jpg", 0, 0, 1177, 137, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER))
$Trackingbtn = GUICtrlCreateButton("Tracking", 8, 296, 169, 49)
$Loadbtn = GUICtrlCreateButton("Load Guide", 8, 368, 169, 49)
$Quicklinksbtn = GUICtrlCreateButton("QuickLinks", 8, 440, 169, 49)
$Dataloadbtn = GUICtrlCreateButton("Dataload", 8, 512, 169, 49)
$Formsbtn = GUICtrlCreateButton("Forms", 8, 584, 169, 49)
$Logo = GUICtrlCreatePic("C:\Users\webbth\Pictures\Untitled1.jpg", 8, 152, 169, 121, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER))
$Feedbackbtn = GUICtrlCreateButton("Dashboard Feedback", 8, 656, 169, 49)
$MainLogo = GUICtrlCreateLabel("FCGP Dashboard", 400, 32, 420, 63)
GUICtrlSetFont(-1, 48, 400, 0, "Arial Narrow")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
;;;;;;;;;;;;; tab one pics
$PMNotes = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\PMProdNotes.jpg", 840, 568, 113, 65)
$CostsBranch = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\CostsBranch.jpg", 496, 392, 65, 113)
$CostRelease = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\CbranchRelease.jpg", 384, 424, 105, 57)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GUISetState(@SW_SHOW)
$Tab1 = GUICtrlCreateTab(184, 144, 929, 601)
GUICtrlCreateTabItem("Hotel Load")
GUICtrlCreateTabItem("Car Load")
GUISetState()


#EndRegion ### END Koda GUI section ###


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit


EndSwitch
WEnd
Edited by 13lack13lade

Share this post


Link to post
Share on other sites



you misunderstand. you do not need to hide tab contents while a tab is not selected - the tabbing mechanism takes care of that.

this part of your code is improperly commented: it is NOT inside tab one, it is in the main GUI:

;;;;;;;;;;;;; tab one pics
$PMNotes = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\PMProdNotes.jpg", 840, 568, 113, 65)
$CostsBranch = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\CostsBranch.jpg", 496, 392, 65, 113)
$CostRelease = GUICtrlCreatePic("Q:\Documents\Load Support\Tom\Projects\Dashboard\Images\LoadGuide\CbranchRelease.jpg", 384, 424, 105, 57)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

now, change your code into this:

$Tab1 = GUICtrlCreateTab(184, 144, 929, 601)

GUICtrlCreateTabItem("Hotel Load")
GUICtrlCreatePic("C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg", 200, 200)
GUICtrlCreateTabItem("")

GUICtrlCreateTabItem("Car Load")
GUICtrlCreatePic("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg", 200, 200)
GUICtrlCreateTabItem("")

notice the line GUICtrlCreateTabItem("") which 'closes' the tab created by GUICtrlCreateTabItem(), and all items assigned to this tab is between these two lines.

note that i did not simulate your pictures, i just used standard shared pictures shipped with Windows 7.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh i see........ *face palm* thanks orbs :)

I do have a query though, am i able to use it like this GuiCtrlCreatePic($PMNotes) for example? or is there a way to define those pictures as i intend to use them as buttons aswell

Edited by 13lack13lade

Share this post


Link to post
Share on other sites

you can use any object as a button, as long as you assign a Control ID to it. for example, in your code $PMNotes is the Control ID of the pic created by the GUICtrlCreatePic function.

when you click it, GUIGetMsg() returns the Control ID, for example, in your code $GUI_EVENT_CLOSE is the Control ID of the Windows "Close" button.

extra: to make the user realize he can click the picture, you can assign a "hand" mouse cursor to the picture. check out GUICtrlSetCursor()

Share this post


Link to post
Share on other sites

Thanks that made perfect sense and i know have it working perfectly :)

Only issue = second tab loads straight away, is there a way to have the first tab stay open as default?

have tried using GUICtrlSetState(-1, $GUI_SHOW) and hide but doesnt do anything :/

Share this post


Link to post
Share on other sites

Look at GUISwitch, and if that's not enough of a hint, search for it and "tab" here on the forum.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

i have tried however it will only switch to first tab then switch back to second straight away... doing something wrong! :(

Edited by 13lack13lade

Share this post


Link to post
Share on other sites

the example for GUICtrlCreateTabItem() in the help is exactly what you need. pay close attention to where the line GUICtrlSetState(-1, $GUI_SHOW) is located in the script - right after you create the tab that you want to be displayed first!

Share this post


Link to post
Share on other sites

Sorted it out - found what my dilemma was.. due to going back and forth using Koda i managed to get a couple of unwanted:

GUISetState(@SW_SHOW)

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