Jump to content
Sign in to follow this  
zuk

_GUICtrlComboBoxEx_Create and GUICtrlCreateTab pb

Recommended Posts

zuk

Hello,

I'm not a developer, and got some troubles to complete a little GUI that I want to use for my job.

At the begining, I made all simple actions, and was ok.

Then, I got to use an ini file + combo box to read it and allow users to select their value.

I did this, with _GUICtrlComboBoxEx.

But now, I want to implement that within my little interface which is running 4 tabs, using GUICtrlCreateTab + GUICtrlCreateTabItem.

Unfortunately, I can't display my _GUICtrlComboBoxEx only in my Tab2...

Either the comboxex is displayed all the time, everywhere (all tabs), or not displayed at all... :mellow:

I searched all around, I tried to used this Rasim exemple (thx to him):

Link to Rasim exemple

But I can't make it work with my needs :( ... For me it's too complicated to understand the "$WM_NOTIFY" use, so I can't adapt/use it.

Please help me !! (Thx per advance !!)

Here's a sample of my interface with my pb:

#include <GUIConstantsEx.au3>
#Include <GuiComboBoxEx.au3>
#Include <File.au3>
;#include <MsgBoxDJS.au3>
#include <Process.au3>

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#Include <WinAPI.au3>

Global $Section,$tab,$combo,$tab0,$tab1,$tab2,$tab3,$gui
;$Debug_CB = False
;$Debug_TAB = False

;########################################################################################

;########################################################################################

;vérification du fichier ini
$IniFile = (@ScriptDir & "\pc.ini")
;   If FileExists($IniFile) = 0 Then
;       MsgBox(16,"Erreur:","pc.ini non trouvé !")
;       Exit
;   EndIf
$List_Pc = IniRead($IniFile,"LISTPC","LIST","")
;fin de vérif fichier ini
;########################################################################################
; ini
;$IP = IniRead($IniFile,$Section,"IP","")
;$PORT = IniRead($IniFile,$Section,"PORTUVNC","")
;$MAC = IniRead($IniFile,$Section,"MAC","")
;$PORT_WoL = IniRead($IniFile,$Section,"PORTWOL","")
;$MASK = IniRead($IniFile,$Section,"MASK","")

;########################################################################################

Interface()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;#####################- Interface -###################################################################
Func Interface()
    Local $tab, $tab0_connexions, $tab0_OK, $tab0_S, $tab0_deconnecter
    Local $tab3, $tab3_OK, $tab3_start_pc1, $tab3_uvnc_pc1
    Local $tab1, $tab1_user, $tab1_pwd, $tab1_OK
    Local $tab2, $tab2_OK, $msg

    $gui = GUICreate("Sample",380,300,500,300)
    GUISetFont(9, 300)

    $tab = GUICtrlCreateTab(10, 10, 360, 280)

    $tab0_connexions = GUICtrlCreateTabItem("Tab 1")
    GUICtrlSetState(-1, $GUI_SHOW)  ; will be display first
    $tab0_OK = GUICtrlCreateButton("Quit",300,250,50,30)
    ;...


    $tab3 = GUICtrlCreateTabItem ("Tab 2")
    $combo = _GUICtrlComboBoxEx_Create ($gui,$List_Pc,20,60,180,300)
    $tab3_start_pc1 = GUICtrlCreateButton("buttontab3",220,50,80,30)
    ;...
    WinSetState($combo, "", @SW_HIDE)


    $tab1 = GUICtrlCreateTabItem("Tab 3")
    GUICtrlCreateLabel("text",45,55,150,25)
    $tab1_user = GUICtrlCreateInput("",180,50,150,25)
    GUICtrlCreateLabel("text",55,105,150,25)
    ;...


    $tab2 = GUICtrlCreateTabItem("Tab 4")
    GUICtrlCreateLabel("stuff to write",20,40,300,30)
    $tab2_OK = GUICtrlCreateButton("Quit",300,250,50,30)
    ;...


    GUICtrlCreateTabItem("")    ; end tabitem definition
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState()


    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

        Select
;#####################- tab0 -###################################################################
            Case $msg = $tab0_S
            ;blablabla
                Sleep("10")
;#####################- tab1 -###################################################################

            Case $msg = $tab1_user
                Sleep("10")
;#####################- tab2 -###################################################################
            Case $msg = $tab2_OK
                Sleep("10")
;#####################- tab3 -###################################################################
            Case $msg = $tab3_start_pc1
                _GUICtrlComboBoxEx_BeginUpdate ($combo)
                _GUICtrlComboBoxEx_EndUpdate ($combo)
                _GUICtrlComboBoxEx_GetItemText ($combo, _GUICtrlComboBoxEx_GetCurSel($combo), $Section)




                ;blablabla

;############################################
            Case $msg = $tab3_uvnc_pc1
                Sleep("10")

;############################################
            Case $msg = $tab3_OK
                Exit

        EndSelect
    WEnd
EndFunc   ;==>Interface

;#####################################################################################################

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndTab, $tNMHDR, $HwndFrom, $iCode

    $hWndTab = $tab
    If Not IsHWnd($hWndTab) Then $hWndTab = GUICtrlGetHandle($tab)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $HwndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $HwndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE

                    Switch _GUICtrlTab_GetCurSel($tab)

                        Case 0
                            _WinAPI_ShowWindow($combo,0)

                        Case 1
                            _WinAPI_ShowWindow($combo,5)

                        Case 2
                            _WinAPI_ShowWindow($combo,0)

                        Case 3
                            _WinAPI_ShowWindow($combo,0)

                    EndSwitch
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc
;#####################################################################################################
Func uVNC()
    ;blabla
    Sleep("10")
EndFunc
;#####################################################################################################
Func Start_Pc()
    ;blabla
    Sleep("10")
EndFunc

Share this post


Link to post
Share on other sites
Melba23

zuk,

Just Hide/Show the combo depending on which tab is selected - you need to add another Case to your loop as you can see here: :(

#include <GuiComboBoxEx.au3>
#include <File.au3>
;#include <MsgBoxDJS.au3>
#include <Process.au3>

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <WinAPI.au3>

Global $Section, $tab, $combo, $tab0, $tab1, $tab2, $tab3, $gui
;$Debug_CB = False
;$Debug_TAB = False

;########################################################################################

;########################################################################################

;vérification du fichier ini
$IniFile = (@ScriptDir & "\pc.ini")
;   If FileExists($IniFile) = 0 Then
;       MsgBox(16,"Erreur:","pc.ini non trouvé !")
;       Exit
;   EndIf
$List_Pc = IniRead($IniFile, "LISTPC", "LIST", "")
;fin de vérif fichier ini
;########################################################################################
; ini
;$IP = IniRead($IniFile,$Section,"IP","")
;$PORT = IniRead($IniFile,$Section,"PORTUVNC","")
;$MAC = IniRead($IniFile,$Section,"MAC","")
;$PORT_WoL = IniRead($IniFile,$Section,"PORTWOL","")
;$MASK = IniRead($IniFile,$Section,"MASK","")

;########################################################################################

Interface()

Exit

;#####################- Interface -###################################################################
Func Interface()
    Local $tab, $tab0_connexions, $tab0_OK, $tab0_S, $tab0_deconnecter
    Local $tab3, $tab3_OK, $tab3_start_pc1, $tab3_uvnc_pc1
    Local $tab1, $tab1_user, $tab1_pwd, $tab1_OK
    Local $tab2, $tab2_OK, $msg

    $gui = GUICreate("Sample", 380, 300, 500, 300)
    GUISetFont(9, 300)
    
    $tab = GUICtrlCreateTab(10, 10, 360, 280)

    $tab0_connexions = GUICtrlCreateTabItem("Tab 0")
    GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
    $combo = _GUICtrlComboBoxEx_Create($gui, $List_Pc, 20, 60, 180, 300)
    $tab0_OK = GUICtrlCreateButton("Quit", 300, 250, 50, 30)
    ;...

    $tab1 = GUICtrlCreateTabItem("Tab 1")
    $tab1_start_pc1 = GUICtrlCreateButton("buttontab1", 220, 50, 80, 30)
    ;...

    $tab2 = GUICtrlCreateTabItem("Tab 2")
    GUICtrlCreateLabel("text", 45, 55, 150, 25)
    $tab2_user = GUICtrlCreateInput("", 180, 50, 150, 25)
    GUICtrlCreateLabel("text", 55, 105, 150, 25)
    ;...

    $tab3 = GUICtrlCreateTabItem("Tab 3")
    GUICtrlCreateLabel("stuff to write", 20, 40, 300, 30)
    $tab3_OK = GUICtrlCreateButton("Quit", 300, 250, 50, 30)
    ;...

    GUICtrlCreateTabItem("") ; end tabitem definition

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        ;If $msg = $GUI_EVENT_CLOSE Then ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        Select
            Case $msg = $GUI_EVENT_CLOSE ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                Return
                ;#####################- tab0 -###################################################################
            Case $msg = $tab0_OK
                ;blablabla
                Sleep("10")
                ;#####################- tab1 -###################################################################
            Case $msg = $tab2_user
                Sleep("10")
                ;#####################- tab2 -###################################################################
            Case $msg = $tab3_OK
                Sleep("10")
                ;#####################- tab3 -###################################################################
            Case $msg = $tab1_start_pc1
                _GUICtrlComboBoxEx_BeginUpdate($combo)
                _GUICtrlComboBoxEx_EndUpdate($combo)
                _GUICtrlComboBoxEx_GetItemText($combo, _GUICtrlComboBoxEx_GetCurSel($combo), $Section)
                ;blablabla
                ;############################################
            Case $msg = $tab3_uvnc_pc1
                Sleep("10")
                ;############################################
            Case $msg = $tab3_OK
                Exit
            Case $tab ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                ; Show/Hide the combo as required
                Switch GUICtrlRead($tab)
                    Case 0
                        WinSetState($combo, "", @SW_SHOW)
                    Case Else
                        WinSetState($combo, "", @SW_HIDE)
                EndSwitch

        EndSelect
    WEnd
EndFunc   ;==>Interface

;#####################################################################################################

;#####################################################################################################
Func uVNC()
    ;blabla
    Sleep("10")
EndFunc   ;==>uVNC
;#####################################################################################################
Func Start_Pc()
    ;blabla
    Sleep("10")
EndFunc   ;==>Start_Pc

A couple of other points:

1. I changed your tab numbering - you might be able to cope with Tabs having non-consecutive numbering, but I cannot! :mellow:

2. You needed 2 clicks on the [X] to exit - because you had 2 loops looking for the CLOSE event. I suggest that you only ever use one - either exit directly from the inner loop, or do not have a loop in the main script (as here).

Look for the <<<<<<<<<<<<<<<<<<< lines.

I hope it is all clear - please ask if not. :lol:

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
zuk

Yes well done THANK YOU VERY MUCH Melba23 ! :mellow:

It's already working like that, it's clear... But I have 1 more little question:

Is that possible to set the _GUICtrlComboBoxEx on another tab than "tab 0" ? (for exemple on "tab 1").

I tried but I failed, I have just 1 GUICtrlCreateTab, and its's not working when setting GUICtrlCreateTabItem in the:

Switch GUICtrlRead($tab) -> line: 109

Any idea please ??

Share this post


Link to post
Share on other sites
Melba23

zuk,

Easy, just change the tab index in the Case structure:

Case $tab
    ; Show/Hide the combo as required
    Switch GUICtrlRead($tab)
        Case 1  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            WinSetState($combo, "", @SW_SHOW)
        Case Else
            WinSetState($combo, "", @SW_HIDE)
    EndSwitch

This will put the combo on Tab 1. :mellow:

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
Yashied
zuk

Thx for your replies.

I'm using _GUICtrlComboBoxEx because it allows me to read an INI file with separators, easily.

Melba23 it's ok, it's working on any others tab.

The little "small" detail is that on my pc, it's taking up 1 or 2 seconds to be displayed/hidden when switching tabs.

But it's not really important, as it's making the job ! :mellow:

(well if you know why this is happening, tell me it's always good to understand !)

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  

×