Sign in to follow this  
Followers 0
TokGajah

Alternative way to do like Child Tab but...

3 posts in this topic

The good thing about Koda Form Designer is a newbie like me can create a GUI easily even with basic knowledge. The bad thing is come when the newbie with basic knowledge having trouble with the GUI and can't debug by himself :D

Hi all. Initially i wish to create several child tab under a tab, and in the child tab it have one List box. Since the child tab can't be create in the Koda Form Designer, as a workaround to a newbie, i have choose the radio button for the replacement. Several list box will be overlay in the same position and the radio button will help to switch the right list box. The state for the right list box will be show and other list box will be hide.

Posted Image

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

#Region ### START Koda GUI section ### Form=D:\Desktop\testing.kxf
$Form1 = GUICreate("Tabbed Notebook Dialog", 413, 305, 303, 219)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$List1 = GUICtrlCreateList("", 28, 65, 361, 160)
GUICtrlSetData(-1, "ListBox 1- Value 1|ListBox 1- Value 2")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetState(-1, $GUI_HIDE)
$List2 = GUICtrlCreateList("", 28, 65, 361, 160)
GUICtrlSetData(-1, "ListBox 2 - Value 1|ListBox 2 - Value 2")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetState(-1, $GUI_HIDE)
$Radio1 = GUICtrlCreateRadio("ListBox 1", 28, 41, 65, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio2 = GUICtrlCreateRadio("ListBox 2", 108, 41, 65, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio3 = GUICtrlCreateRadio("ListBox 3", 196, 41, 65, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$List3 = GUICtrlCreateList("", 28, 65, 361, 160)
GUICtrlSetData(-1, "ListBox 3 - Value 1|ListBox 3 - Value 2")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("&OK", 166, 272, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25, 0)
$Button3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1
            $Show = $List1
            $Hide = $List2
            $Hide2 = $List3
            GuiShowHide($Show, $Hide, $Hide2)
        Case $Radio2
            $Show = $List2
            $Hide = $List1
            $Hide2 = $List3
            GuiShowHide($Show, $Hide, $Hide2)
        Case $Radio3
            $Show = $List3
            $Hide = $List1
            $Hide2 = $List2
            GuiShowHide($Show, $Hide, $Hide2)           
    EndSwitch
WEnd

Func GuiShowHide($Show, $Hide, $Hide2)
    GUICtrlSetState($Show, $GUI_SHOW)
    GUICtrlSetState($Hide, $GUI_HIDE)
    GUICtrlSetState($Hide2, $GUI_HIDE)
EndFunc

The problem to the script right now is the List box will flickering when i switch between the radio buttons. Is there any bad practice with the code that i did?

Share this post


Link to post
Share on other sites



I don't see any flicker, but you may want a sleep in your while loop. This will make it so you don't use as much processor.


Giggity

Share this post


Link to post
Share on other sites

Thanks for the reply

The flicker will happen at quick time when you switch between the radio button. Try to switch the radio button at fast rate and do it more than 10 time, and you can see the flickering occur. I try the suggestion by putting the sleep in while loop, and i also try to put it in the case statement but it did not solve the problem

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