zuk Posted March 9, 2010 Share Posted March 9, 2010 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... I searched all around, I tried to used this Rasim exemple (thx to him):Link to Rasim exempleBut 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:expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2010 Moderators Share Posted March 10, 2010 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: expandcollapse popup#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_PcA 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! 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. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zuk Posted March 10, 2010 Author Share Posted March 10, 2010 Yes well done THANK YOU VERY MUCH Melba23 ! 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 ?? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2010 Moderators Share Posted March 10, 2010 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) EndSwitchThis will put the combo on Tab 1. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Yashied Posted March 10, 2010 Share Posted March 10, 2010 zuk, why do not use native GUICtrlCreateCombo() function. Your problem will be solved by itself. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
zuk Posted March 11, 2010 Author Share Posted March 11, 2010 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 ! (well if you know why this is happening, tell me it's always good to understand !) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now