kor Posted March 23, 2011 Share Posted March 23, 2011 I found some sample code on the forums the other day that did exactly what I wanted to do, which was tab items within tab items. I have modified the code quite a bit and can't figure out why I am not able to accomplish 2 important things. 1) be able to tab through the input boxes 2) be able to hit enter on any of the input boxes and it treat it as me clicking the "create" button Here is my code. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Include <GuiComboBox.au3> #Include <Array.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> ; Global variables Global $vararray[16][2] Global $validated $maingui = GUICreate("ADAM v1.0", 285, 290) ; will create a dialog box that when displayed is centered ; # Staff Tabs # =============================================================================================================== $staffgui = GUICreate("", 280, 265, 2, 21, BitOR($WS_CHILD, $WS_TABSTOP), -1, $maingui) $stafftab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create staff tab GUICtrlCreateTabItem("Create Staff") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[0][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[1][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Staff ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[2][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[3][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") GUICtrlCreateLabel("Job Title :", 25, 139, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[4][0] = GUICtrlCreateCombo("", 100, 137, 135, 20, $SS_RIGHT) GUICtrlSetData(-1, "Job Titles") ; job titles GUICtrlCreateLabel("Classification :", 20, 164, 70, 20, $SS_RIGHT) ; left, top, width, height $vararray[5][0] = GUICtrlCreateCombo("", 100, 162, 135, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Certified (T)|Classified (C)") ; Create buttons $createstaff = GUICtrlCreateButton("&Create", 25, 225, 95, 25) $reset1 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Delete staff tab GUICtrlCreateTabItem("Delete Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[6][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestaff = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) $reset2 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move staff tab GUICtrlCreateTabItem("Move Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[7][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[8][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") ; Move buttons $movestaff = GUICtrlCreateButton("&Move", 25, 225, 95, 25) $reset3 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Student Tabs # ============================================================================================================== $studentgui = GUICreate("", 280, 265, 2, 21, BitOR($WS_CHILD, $WS_TABSTOP), -1, $maingui) ; left and right are for child tabs $studenttab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create student tab GUICtrlCreateTabItem("Create Student") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[9][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[10][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Student ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[11][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[12][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") GUICtrlCreateLabel("Accounts should only be created for students in 2nd grade or above.", 45, 150, 195, 50, $SS_CENTER) ; Create buttons $createstudent = GUICtrlCreateButton("&Create", 25, 225, 95, 25) $reset4 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlSetState($createstaff, $GUI_DEFBUTTON) ; Delete student tab GUICtrlCreateTabItem("Delete Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[13][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestudent = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) $reset5 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move student tab $movestudent = GUICtrlCreateTabItem("Move Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[14][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[15][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") ; Move buttons $movestudent = GUICtrlCreateButton("&Move", 25, 225, 95, 25) $reset6 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Main Tabs # ================================================================================================================= GUISwitch($maingui) $tab = GUICtrlCreateTab(0, 0, 285, 290) ; main tab $tab0 = GUICtrlCreateTabItem("Staff Account") ; primary staff tab $tab1 = GUICtrlCreateTabItem("Student Account") ; primary student tab GUICtrlCreateTabItem("") ; end tabitem definition ;================================================================================================================================ GUISetState() GUISetState(@SW_SHOW, $staffgui) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $tab Select Case GUICtrlRead($tab) = 0 GUISetState(@SW_SHOW, $staffgui) GUISetState(@SW_HIDE, $studentgui) consolewrite("staff tab" & @CR) Case GUICtrlRead($tab) = 1 GUISetState(@SW_SHOW, $studentgui) GUISetState(@SW_HIDE, $staffgui) consolewrite("student tab" & @CR) EndSelect Case $msg = $reset1 Or $msg = $reset2 Or $msg = $reset3 Or $msg = $reset4 Or $msg = $reset5 Or $msg = $reset6 consolewrite("reset pressed" & @CR) _SelfRestart() Case $msg = $createstaff consolewrite("create staff pressed" & @CR) _ValidateCreateStaff() If $validated = True Then _CreateStaff() Case $msg = $deletestaff consolewrite("delete staff pressed" & @CR) _ValidateDeleteStaff() If $validated = True Then _DeleteStaff() Case $msg = $movestaff consolewrite("move staff pressed" & @CR) _ValidateMoveStaff() If $validated = True Then _MoveStaff() Case $msg = $createstudent consolewrite("create student pressed" & @CR) _ValidateCreateStudent() If $validated = True Then _CreateStudent() Case $msg = $deletestudent consolewrite("delete student pressed" & @CR) _ValidateDeleteStudent() If $validated = True Then _DeleteStudent() Case $msg = $movestudent consolewrite("move student pressed" & @CR) _ValidateMoveStudent() If $validated = True Then _MoveStudent() EndSelect WEnd Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==> _SelfRestart Func _ValidateCreateStaff() Select Case GUICtrlRead($vararray[0][0]) = "" $validated = False MsgBox(16, "Error", "First Name cannot be blank") GUICtrlSetState($vararray[0][0], $GUI_FOCUS) Case GUICtrlRead($vararray[1][0]) = "" $validated = False MsgBox(16, "Error", "Last Name cannot be blank") GUICtrlSetState($vararray[1][0], $GUI_FOCUS) Case GUICtrlRead($vararray[2][0]) = "" $validated = False MsgBox(16, "Error", "Staff ID cannot be blank") GUICtrlSetState($vararray[2][0], $GUI_FOCUS) Case GUICtrlRead($vararray[3][0]) = "" $validated = False MsgBox(16, "Error", "Location cannot be blank") GUICtrlSetState($vararray[3][0], $GUI_FOCUS) Case GUICtrlRead($vararray[4][0]) = "" $validated = False MsgBox(16, "Error", "Job Title cannot be blank") GUICtrlSetState($vararray[4][0], $GUI_FOCUS) Case GUICtrlRead($vararray[5][0]) = "" $validated = False MsgBox(16, "Error", "Classification cannot be blank") GUICtrlSetState($vararray[5][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[0][0] = GUICtrlRead($vararray[0][0]) $vararray[1][0] = GUICtrlRead($vararray[1][0]) $vararray[2][0] = GUICtrlRead($vararray[2][0]) $vararray[3][0] = GUICtrlRead($vararray[3][0]) $vararray[4][0] = GUICtrlRead($vararray[4][0]) $vararray[5][0] = GUICtrlRead($vararray[5][0]) EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 (edited) kor,Change the styles for your 2 child GUIs to $WS_CHILD, $WS_EX_CONTROLPARENT and then your inputs will respond to the Tab key as you expect. And before you ask, it is the $WS_EX_CONTROLPARENT extended style that gets the TABSTOPs to work on child windows, as without that style the child GUI is tabbed as one control. However, be aware that because of internal AutoIt coding (explained in Trac ticket #1115) there are some side-effects which fortunately will not bother you here. Edit: Sorry - missed the second question.One way to do get "Enter" to act as you wish is to look for the "Enter" key being pressed and then actioning a dummy control which would fire the same code as the button. Take a look at this (look for the <<<<<<<<<<<<< lines):expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Include <GuiComboBox.au3> #Include <Array.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <WinAPI.au3> ; Global variables Global $vararray[16][2] Global $validated $dll = DllOpen("user32.dll") $maingui = GUICreate("ADAM v1.0", 285, 290) ; will create a dialog box that when displayed is centered ; # Staff Tabs # =============================================================================================================== $staffgui = GUICreate("", 280, 265, 2, 21, $WS_CHILD, $WS_EX_CONTROLPARENT, $maingui) $stafftab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create staff tab GUICtrlCreateTabItem("Create Staff") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[0][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[1][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Staff ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[2][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[3][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") GUICtrlCreateLabel("Job Title :", 25, 139, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[4][0] = GUICtrlCreateCombo("", 100, 137, 135, 20, $SS_RIGHT) GUICtrlSetData(-1, "Job Titles") ; job titles GUICtrlCreateLabel("Classification :", 20, 164, 70, 20, $SS_RIGHT) ; left, top, width, height $vararray[5][0] = GUICtrlCreateCombo("", 100, 162, 135, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Certified (T)|Classified ©") ; Create buttons $createstaff = GUICtrlCreateButton("&Create", 25, 225, 95, 25) $createstaff_dummy = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Dummy to fire when Enter pressed in input $reset1 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Delete staff tab GUICtrlCreateTabItem("Delete Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[6][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestaff = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) $reset2 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move staff tab GUICtrlCreateTabItem("Move Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[7][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[8][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") ; Move buttons $movestaff = GUICtrlCreateButton("&Move", 25, 225, 95, 25) $reset3 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Student Tabs # ============================================================================================================== $studentgui = GUICreate("", 280, 265, 2, 21, $WS_CHILD, $WS_EX_CONTROLPARENT, $maingui) ; left and right are for child tabs $studenttab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create student tab GUICtrlCreateTabItem("Create Student") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[9][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[10][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Student ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[11][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[12][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") GUICtrlCreateLabel("Accounts should only be created for students in 2nd grade or above.", 45, 150, 195, 50, $SS_CENTER) ; Create buttons $createstudent = GUICtrlCreateButton("&Create", 25, 225, 95, 25) $reset4 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlSetState($createstaff, $GUI_DEFBUTTON) ; Delete student tab GUICtrlCreateTabItem("Delete Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[13][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestudent = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) $reset5 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move student tab $movestudent = GUICtrlCreateTabItem("Move Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[14][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[15][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Locations") ; Move buttons $movestudent = GUICtrlCreateButton("&Move", 25, 225, 95, 25) $reset6 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Main Tabs # ================================================================================================================= GUISwitch($maingui) $tab = GUICtrlCreateTab(0, 0, 285, 290) ; main tab $tab0 = GUICtrlCreateTabItem("Staff Account") ; primary staff tab $tab1 = GUICtrlCreateTabItem("Student Account") ; primary student tab GUICtrlCreateTabItem("") ; end tabitem definition ;================================================================================================================================ GUISetState() GUISetState(@SW_SHOW, $staffgui) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $tab Select Case GUICtrlRead($tab) = 0 GUISetState(@SW_SHOW, $staffgui) GUISetState(@SW_HIDE, $studentgui) consolewrite("staff tab" & @CR) Case GUICtrlRead($tab) = 1 GUISetState(@SW_SHOW, $studentgui) GUISetState(@SW_HIDE, $staffgui) consolewrite("student tab" & @CR) EndSelect Case $msg = $reset1 Or $msg = $reset2 Or $msg = $reset3 Or $msg = $reset4 Or $msg = $reset5 Or $msg = $reset6 consolewrite("reset pressed" & @CR) _SelfRestart() Case $msg = $createstaff Or $msg = $createstaff_dummy ; Action the button or the dummy <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< consolewrite("create staff pressed" & @CR) ;_ValidateCreateStaff() ;If $validated = True Then _CreateStaff() Case $msg = $deletestaff consolewrite("delete staff pressed" & @CR) ;_ValidateDeleteStaff() ;If $validated = True Then _DeleteStaff() Case $msg = $movestaff consolewrite("move staff pressed" & @CR) ;_ValidateMoveStaff() ;If $validated = True Then _MoveStaff() Case $msg = $createstudent consolewrite("create student pressed" & @CR) ;_ValidateCreateStudent() ;If $validated = True Then _CreateStudent() Case $msg = $deletestudent consolewrite("delete student pressed" & @CR) ;_ValidateDeleteStudent() ;If $validated = True Then _DeleteStudent() Case $msg = $movestudent consolewrite("move student pressed" & @CR) ;_ValidateMoveStudent() ;If $validated = True Then _MoveStudent() EndSelect ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If _IsPressed("0D", $dll) Then ; Is Enter pressed? $hFocus = _WinAPI_GetFocus() ; What has focus Switch $hFocus Case GUICtrlGetHandle($vararray[0][0]), GUICtrlGetHandle($vararray[1][0]), GUICtrlGetHandle($vararray[2][0]) ; If an input GUICtrlSendToDummy($createstaff_dummy) ; Fire the dummy control EndSwitch While _IsPressed("0D") ; And wait until Enter is released or we get multiple firings Sleep(10) WEnd EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WEnd Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf DllClose($dll) Exit EndFunc ;==> _SelfRestart Func _ValidateCreateStaff() Select Case GUICtrlRead($vararray[0][0]) = "" $validated = False MsgBox(16, "Error", "First Name cannot be blank") GUICtrlSetState($vararray[0][0], $GUI_FOCUS) Case GUICtrlRead($vararray[1][0]) = "" $validated = False MsgBox(16, "Error", "Last Name cannot be blank") GUICtrlSetState($vararray[1][0], $GUI_FOCUS) Case GUICtrlRead($vararray[2][0]) = "" $validated = False MsgBox(16, "Error", "Staff ID cannot be blank") GUICtrlSetState($vararray[2][0], $GUI_FOCUS) Case GUICtrlRead($vararray[3][0]) = "" $validated = False MsgBox(16, "Error", "Location cannot be blank") GUICtrlSetState($vararray[3][0], $GUI_FOCUS) Case GUICtrlRead($vararray[4][0]) = "" $validated = False MsgBox(16, "Error", "Job Title cannot be blank") GUICtrlSetState($vararray[4][0], $GUI_FOCUS) Case GUICtrlRead($vararray[5][0]) = "" $validated = False MsgBox(16, "Error", "Classification cannot be blank") GUICtrlSetState($vararray[5][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[0][0] = GUICtrlRead($vararray[0][0]) $vararray[1][0] = GUICtrlRead($vararray[1][0]) $vararray[2][0] = GUICtrlRead($vararray[2][0]) $vararray[3][0] = GUICtrlRead($vararray[3][0]) $vararray[4][0] = GUICtrlRead($vararray[4][0]) $vararray[5][0] = GUICtrlRead($vararray[5][0]) EndIf EndFuncYou could use a message handler to look for the "Enter" key as well - I used _IsPressed becasue it is easy to code a proof of concept demo like this.By the way, notice how using Switch rather then Select makes multiple Cases much easier to code. Please ask if you have any questions. M23 Edited March 23, 2011 by Melba23  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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 I have modified the following 2 items with no change. $staffgui = GUICreate("", 280, 265, 2, 21, BitOR($WS_CHILD, $WS_EX_CONTROLPARENT), -1, $maingui) $studentgui = GUICreate("", 280, 265, 2, 21, BitOR($WS_CHILD, $WS_EX_CONTROLPARENT), -1, $maingui) I'm also still wondering how to get the "enter" key to press the "create" button Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 kor,Look at the the styles I suggested -the second is an EXTENDED style! So your line should read like this:$staffgui = GUICreate("", 280, 265, 2, 21, $WS_CHILD, $WS_EX_CONTROLPARENT, $maingui)And I have edited the post above to cover the second question as well.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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 (edited) Thank you very much. The tabs now work correctly. On the enter button, after looking at your code is there a way to create dummy controls for each of the 6 possible "enter" buttons on the tabs without having to duplicate the code 6 times for the 6 different variables? createstaff dummy movestaff dummy deletestaff dummy createstudent dummy movestudent dummy deletestudent dummy Maybe something like this? ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If _IsPressed("0D", $dll) Then ; Is Enter pressed? $hFocus = _WinAPI_GetFocus() ; What has focus Switch $hFocus Case GUICtrlGetHandle($vararray[0][0]), GUICtrlGetHandle($vararray[1][0]), GUICtrlGetHandle($vararray[2][0]) ; If an input GUICtrlSendToDummy($createstaff_dummy) ; Fire the dummy control Case GUICtrlGetHandle($vararray[5][0]), GUICtrlGetHandle($vararray[6][0]), GUICtrlGetHandle($vararray[7][0]) ; If an input GUICtrlSendToDummy($deletestaff_dummy) ; Fire the dummy control Case GUICtrlGetHandle($vararray[10][0]), GUICtrlGetHandle($vararray[11][0]), GUICtrlGetHandle($vararray[12][0]) ; If an input GUICtrlSendToDummy($movestaff_dummy) ; Fire the dummy control EndSwitch While _IsPressed("0D") ; And wait until Enter is released or we get multiple firings Sleep(10) WEnd EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Edited March 23, 2011 by kor Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 kor, Your suggested code is exactly how I would do it. 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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 (edited) I'm running into an issue such that when I run the gui it is immediately going into an endless loop of "first name cannot be blank" before I even hit the enter button. EDIT: I see that you have commented out my validate functions, but even if I do that on my newer code the loop is still going crazy as evidenced by the consolewrite "create button pressed" being endless. Have you changed some other piece of code somewhere? EDIT2: nevermind, found the code $createstaff_dummy = GUICtrlCreateDummy() I'm noticing that looking for _IsPressed might not be the best way. Since later in the function when I do my error checking to see if the inputs are blank, I pop up a message box with an error. If the person pressed "enter" to clear the message box a loop could occur. Edited March 23, 2011 by kor Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 kor,Have you changed some other piece of code somewhere?Only the lines I indicated and if I uncomment the _ValidateCreateStaff() line I do not get the same problem.Please post the whole script that is giving you trouble and I will take a look. 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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 that is the whole script so far. See my edits above. If the validate function runs, and pops up an error message and a user hits enter to clear the error (instead of space bar or clicking ok) a loop can occur because the IsPressed is looking for any time the enter button is pressed. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 kor,The problem is that the "Enter" key press used to close the Error MsgBox is returning so quickly that the key is still pressed as we reenter the main script GUIGetMsg loop. If you wait at the end of your Validate funtion until the "Enter" key is released, then it works as you would expect: Func _ValidateCreateStaff() Select [lots of code] EndIf ; Add this to wait for the key to be released <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While _IsPressed("0D", $dll) Sleep(10) WEnd EndFuncHow is that? 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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 (edited) Perfect! Now after the error box the focus correctly returns to the input. The only thing left is an issue with multiple GuiCtrlCreateDummy Here is my updated code. As you can see I have multiple create dummy's for each of the 6 possible buttons on the tabs. However as soon as I uncomment them and lunch the gui I get an error message that seems as though the gui is trying to press the button on a tab that isn't even being worked on. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Include <GuiComboBox.au3> #Include <Array.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Misc.au3> ; Global variables Global $vararray[16][2] Global $validated Global $createstaffdummy, $deletestaffdummy, $movestaffdummy Global $createstudentdummy, $deletestudentdummy, $movestudentdummy Global $dll = DllOpen("user32.dll") $maingui = GUICreate("ADAM v1.0", 285, 290) ; will create a dialog box that when displayed is centered ; # Staff Tabs # =============================================================================================================== $staffgui = GUICreate("", 280, 265, 2, 21, $WS_CHILD, $WS_EX_CONTROLPARENT, $maingui) $stafftab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create staff tab $createstaffchildtab = GUICtrlCreateTabItem("Create Staff") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[0][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[1][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Staff ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[2][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[3][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "") GUICtrlCreateLabel("Job Title :", 25, 139, 65, 20, $SS_RIGHT) ; left,x top, width, height $vararray[4][0] = GUICtrlCreateCombo("", 100, 137, 135, 20, $SS_RIGHT) GUICtrlSetData(-1, "") ; job titles GUICtrlCreateLabel("Classification :", 20, 164, 70, 20, $SS_RIGHT) ; left, top, width, height $vararray[5][0] = GUICtrlCreateCombo("", 100, 162, 135, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "Certified (T)|Classified (C)") ; Create buttons $createstaff = GUICtrlCreateButton("&Create", 25, 225, 95, 25) $createstaffdummy = GUICtrlCreateDummy() $reset1 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Delete staff tab $deletestaffchildtab = GUICtrlCreateTabItem("Delete Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[6][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestaff = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) ;$deletestaffdummy = GUICtrlCreateDummy() $reset2 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move staff tab $movestaffchildtab = GUICtrlCreateTabItem("Move Staff") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[7][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[8][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "") ; Move buttons $movestaff = GUICtrlCreateButton("&Move", 25, 225, 95, 25) ;$movestaffdummy = GUICtrlCreateDummy() $reset3 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Student Tabs # ============================================================================================================== $studentgui = GUICreate("", 280, 265, 2, 21, $WS_CHILD, $WS_EX_CONTROLPARENT, $maingui) ; left and right are for child tabs $studenttab = GUICtrlCreateTab(0, 0, 280, 265) ; left and right are child tab border ; Create student tab GUICtrlCreateTabItem("Create Student") GUICtrlCreateLabel("First Name :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[9][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("Last Name :", 25, 63, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[10][0] = GUICtrlCreateInput("", 100, 61, 135, 20) GUICtrlCreateLabel("Student ID :", 25, 89, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[11][0] = GUICtrlCreateInput("", 100, 86, 135, 20) GUICtrlCreateLabel("Location :", 25, 114, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[12][0] = GUICtrlCreateCombo("", 100, 111, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "") GUICtrlCreateLabel("Accounts should only be created for students in 2nd grade or above.", 45, 150, 195, 50, $SS_CENTER) ; Create buttons $createstudent = GUICtrlCreateButton("&Create", 25, 225, 95, 25) ;$createstudentdummy = GUICtrlCreateDummy() $reset4 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Delete student tab GUICtrlCreateTabItem("Delete Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[13][0] = GUICtrlCreateInput("", 100, 36, 135, 20) ; Delete buttons $deletestudent = GUICtrlCreateButton("&Delete", 25, 225, 95, 25) ;$deletestudentdummy = GUICtrlCreateDummy() $reset5 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) ; Move student tab $movestudent = GUICtrlCreateTabItem("Move Student") GUICtrlCreateLabel("Username :", 25, 38, 65, 20, $SS_RIGHT) ; left, top, width, height $vararray[14][0] = GUICtrlCreateInput("", 100, 36, 135, 20) GUICtrlCreateLabel("New Location :", 15, 63, 75, 20, $SS_RIGHT) ; left, top, width, height $vararray[15][0] = GUICtrlCreateCombo("", 100, 61, 135, 18, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "") ; Move buttons $movestudent = GUICtrlCreateButton("&Move", 25, 225, 95, 25) ;$movestudentdummy = GUICtrlCreateDummy() $reset6 = GUICtrlCreateButton("&Reset", 155, 225, 95, 25) GUICtrlCreateTabItem("") ; end of tabitem definition ;================================================================================================================================ ; # Main Tabs # ================================================================================================================= GUISwitch($maingui) $tab = GUICtrlCreateTab(0, 0, 285, 290) ; main tab $tab0 = GUICtrlCreateTabItem("Staff Account") ; primary staff tab $tab1 = GUICtrlCreateTabItem("Student Account") ; primary student tab GUICtrlCreateTabItem("") ; end tabitem definition ;================================================================================================================================ GUISetState() GUISetState(@SW_SHOW, $staffgui) GUICtrlSetState($vararray[0][0], $GUI_FOCUS) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $tab Select Case GUICtrlRead($tab) = 0 GUISetState(@SW_SHOW, $staffgui) GUISetState(@SW_HIDE, $studentgui) consolewrite("staff tab" & @CR) Case GUICtrlRead($tab) = 1 GUISetState(@SW_SHOW, $studentgui) GUISetState(@SW_HIDE, $staffgui) consolewrite("student tab" & @CR) EndSelect Case $msg = $reset1 Or $msg = $reset2 Or $msg = $reset3 Or $msg = $reset4 Or $msg = $reset5 Or $msg = $reset6 consolewrite("reset pressed" & @CR) _SelfRestart() Case $msg = $createstaff Or $msg = $createstaffdummy consolewrite("create staff pressed" & @CR) _ValidateCreateStaff() If $validated = True Then _CreateStaff() Case $msg = $deletestaff Or $deletestaffdummy consolewrite("delete staff pressed" & @CR) _ValidateDeleteStaff() If $validated = True Then _DeleteStaff() Case $msg = $movestaff Or $movestaffdummy consolewrite("move staff pressed" & @CR) _ValidateMoveStaff() If $validated = True Then _MoveStaff() Case $msg = $createstudent Or $createstudentdummy consolewrite("create student pressed" & @CR) _ValidateCreateStudent() If $validated = True Then _CreateStudent() Case $msg = $deletestudent Or $deletestudentdummy consolewrite("delete student pressed" & @CR) _ValidateDeleteStudent() If $validated = True Then _DeleteStudent() Case $msg = $movestudent Or $movestudentdummy consolewrite("move student pressed" & @CR) _ValidateMoveStudent() If $validated = True Then _MoveStudent() EndSelect If _IsPressed("0D", $dll) Then ; Is Enter pressed? $hFocus = _WinAPI_GetFocus() ; What has focus Switch $hFocus Case GUICtrlGetHandle($vararray[0][0]), GUICtrlGetHandle($vararray[1][0]), GUICtrlGetHandle($vararray[2][0]), GUICtrlGetHandle($vararray[3][0]), GUICtrlGetHandle($vararray[5][0]) ; If an input GUICtrlSendToDummy($createstaffdummy) ; Fire the dummy control Case GUICtrlGetHandle($vararray[6][0]) GUICtrlSendToDummy($deletestaffdummy) Case GUICtrlGetHandle($vararray[7][0]), GUICtrlGetHandle($vararray[8][0]) GUICtrlSendToDummy($movestaffdummy) Case GUICtrlGetHandle($vararray[9][0]), GUICtrlGetHandle($vararray[10][0]), GUICtrlGetHandle($vararray[11][0]), GUICtrlGetHandle($vararray[12][0]) GUICtrlSendToDummy($createstudentdummy) Case GUICtrlGetHandle($vararray[13][0]) GUICtrlSendToDummy($deletestudentdummy) Case GUICtrlGetHandle($vararray[14][0]), GUICtrlGetHandle($vararray[15][0]) GUICtrlSendToDummy($movestudentdummy) Case Else ; do nothing EndSwitch While _IsPressed("0D") ; And wait until Enter is released or we get multiple firings Sleep(10) WEnd EndIf WEnd Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==> _SelfRestart Func _ValidateCreateStaff() Select Case GUICtrlRead($vararray[0][0]) = "" $validated = False MsgBox(16, "Error", "First Name cannot be blank") GUICtrlSetState($vararray[0][0], $GUI_FOCUS) Case GUICtrlRead($vararray[1][0]) = "" $validated = False MsgBox(16, "Error", "Last Name cannot be blank") GUICtrlSetState($vararray[1][0], $GUI_FOCUS) Case GUICtrlRead($vararray[2][0]) = "" $validated = False MsgBox(16, "Error", "Staff ID cannot be blank") GUICtrlSetState($vararray[2][0], $GUI_FOCUS) Case GUICtrlRead($vararray[3][0]) = "" $validated = False MsgBox(16, "Error", "Location cannot be blank") GUICtrlSetState($vararray[3][0], $GUI_FOCUS) Case GUICtrlRead($vararray[4][0]) = "" $validated = False MsgBox(16, "Error", "Job Title cannot be blank") GUICtrlSetState($vararray[4][0], $GUI_FOCUS) Case GUICtrlRead($vararray[5][0]) = "" $validated = False MsgBox(16, "Error", "Classification cannot be blank") GUICtrlSetState($vararray[5][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[0][0] = GUICtrlRead($vararray[0][0]) $vararray[1][0] = GUICtrlRead($vararray[1][0]) $vararray[2][0] = GUICtrlRead($vararray[2][0]) $vararray[3][0] = GUICtrlRead($vararray[3][0]) $vararray[4][0] = GUICtrlRead($vararray[4][0]) $vararray[5][0] = GUICtrlRead($vararray[5][0]) EndIf While _IsPressed("0D", $dll) Sleep(10) WEnd EndFunc ;==> _ValidateCreateStaff Func _ValidateDeleteStaff() Select Case GUICtrlRead($vararray[6][0]) = "" $validated = False MsgBox(16, "Error", "Username cannot be blank") GUICtrlSetState($vararray[6][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[6][0] = GUICtrlRead($vararray[6][0]) EndIf EndFunc ;==> _ValidateDeleteStaff Func _ValidateMoveStaff() Select Case GUICtrlRead($vararray[7][0]) = "" $validated = False MsgBox(16, "Error", "Username cannot be blank") GUICtrlSetState($vararray[7][0], $GUI_FOCUS) Case GUICtrlRead($vararray[8][0]) = "" $validated = False MsgBox(16, "Error", "New Location cannot be blank") GUICtrlSetState($vararray[8][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[7][0] = GUICtrlRead($vararray[7][0]) $vararray[8][0] = GUICtrlRead($vararray[8][0]) EndIf EndFunc ;==> _ValidateMoveStaff Func _ValidateCreateStudent() Select Case GUICtrlRead($vararray[9][0]) = "" $validated = False MsgBox(16, "Error", "First Name cannot be blank") GUICtrlSetState($vararray[9][0], $GUI_FOCUS) Case GUICtrlRead($vararray[10][0]) = "" $validated = False MsgBox(16, "Error", "Last Name cannot be blank") GUICtrlSetState($vararray[10][0], $GUI_FOCUS) Case GUICtrlRead($vararray[11][0]) = "" $validated = False MsgBox(16, "Error", "Student ID cannot be blank") GUICtrlSetState($vararray[11][0], $GUI_FOCUS) Case GUICtrlRead($vararray[12][0]) = "" $validated = False MsgBox(16, "Error", "Location cannot be blank") GUICtrlSetState($vararray[12][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[9][0] = GUICtrlRead($vararray[9][0]) $vararray[10][0] = GUICtrlRead($vararray[10][0]) $vararray[11][0] = GUICtrlRead($vararray[11][0]) $vararray[12][0] = GUICtrlRead($vararray[12][0]) EndIf EndFunc ;==> _ValidateCreateStudent Func _ValidateDeleteStudent() Select Case GUICtrlRead($vararray[13][0]) = "" $validated = False MsgBox(16, "Error", "First Name cannot be blank") GUICtrlSetState($vararray[13][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[13][0] = GUICtrlRead($vararray[13][0]) EndIf EndFunc ;==> _ValidateDeleteStudent Func _ValidateMoveStudent() Select Case GUICtrlRead($vararray[14][0]) = "" $validated = False MsgBox(16, "Error", "Username cannot be blank") GUICtrlSetState($vararray[14][0], $GUI_FOCUS) Case GUICtrlRead($vararray[15][0]) = "" $validated = False MsgBox(16, "Error", "New Location cannot be blank") GUICtrlSetState($vararray[15][0], $GUI_FOCUS) Case Else $validated = True EndSelect If $validated = True Then $vararray[14][0] = GUICtrlRead($vararray[14][0]) $vararray[15][0] = GUICtrlRead($vararray[15][0]) EndIf EndFunc ;==> _ValidateMoveStudent Edited March 23, 2011 by kor Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2011 Moderators Share Posted March 23, 2011 kor,Spot the difference between these 2 lines: Case $msg = $createstaff Or $msg = $createstaffdummy Case $msg = $deletestaff Or $deletestaffdummyIf you want to know why it is important...As the $deletestaffdummy control exists, it is always true and the condition always fires!I did mention earlier that Switch is better for multiple Cases as it has a simpler syntax. 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...
kor Posted March 23, 2011 Author Share Posted March 23, 2011 Fixed. Thank you very much for your help. 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