Jump to content

how to create dynamically a control on a tab


Recommended Posts

Hello,

Here is my script, my question is, how to create dynamically a control on tab "report"? please see my script line 47-48, I used GUISwitch(), but The results of actual runs is not what I want. the actual result is: if I select a template "data", I only can see the input control "aaaa" after clicking tab "version" or "readme". but I hope I can see the input control after I select a template except "report1".

#include <GuiConstantsEx.au3>

_Main()

Func _Main()
    
Global $parent, $tabitem2
; Create the GUI window and controls
    $parent = GUICreate("xxxx", 400, 500, (@DesktopWidth - 400)/ 2, (@DesktopHeight - 500) / 2)
    $OLD = _SetThemes(0)
    GUISetIcon("xxxx")

    $tab = GUICtrlCreateTab(10, 10, 382, 440,0x00000020 )
    _SetThemes($OLD)

    $tabitem1 = GUICtrlCreateTabItem("version")

    $tabitem2 = GUICtrlCreateTabItem("report")
    $radioAddreport = GUICtrlCreateRadio("Add reports", 25, 45, 160, 20, 000000)    
    $radioAddreporttemplate = GUICtrlCreateRadio("Add report template", 200, 45, 150, 20, 000000)
    $bugreporttemplatelabel = GUICtrlCreateLabel("Template", 200, 75, 80, 20, 0x0200)
    $bugreporttemplate = GUICtrlCreateCombo("", 255, 75, 120, 20)   
    GUICtrlSetData($bugreporttemplate, "report1|template|data", "report1")
    GUICtrlCreateTabItem("readme")
    
    GUICtrlCreateTabItem("")

    
; Run the GUI until it is closed
    GUISetState()
            
    While 1

        $msg = GUIGetMsg()
            
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
                case $msg = $tab
                    if GUICtrlRead($tab) = 1 Then
                        $clickAddreport = ControlClick("Wing 1.0","",$radioAddreport)
                    EndIf
                Case $msg = $bugreporttemplate
                    Local $reporttemplate = GUICtrlRead($bugreporttemplate)
                    if $reporttemplate = "report1" Then
                    Else
                        GUISwitch($parent, $tabitem2)
                        GUICtrlCreateInput("aaaa", 125, 135, 250, 20,0x0080)
                    EndIf
            EndSelect
    WEnd

    Exit
EndFunc  ;==>_Main

Func _SetThemes($Style)
    If @OSType = "WIN32_WINDOWS" Or $Style=-1 Then Return SetError(1,0,-1)
    Local $ret = DllCall("uxtheme.dll", "dword", "GetThemeAppProperties")
    If Not IsArray($ret) Then Return SetError(1,0,-1)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "dword", $Style)
    Return $ret[0]
EndFunc

hope your help, thanks.

Link to comment
Share on other sites

"To create a new control on an existing tabitem use GUISwitch($hWin,$tabitem) to select it and just create your new control. Don't forget to close your tabitem creation with GUICtrlCreateTabItem("")."

Add a GUICtrlCreateTabItem("") after the GUICtrlCreateInput().

Link to comment
Share on other sites

"To create a new control on an existing tabitem use GUISwitch($hWin,$tabitem) to select it and just create your new control. Don't forget to close your tabitem creation with GUICtrlCreateTabItem("")."

Add a GUICtrlCreateTabItem("") after the GUICtrlCreateInput().

thank you KaFu, my code is ok now.

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...