Allow2010 Posted January 4, 2013 Share Posted January 4, 2013 Hi, i created a gui that uses tabs (GUICtrlCreateTab). I use inputs in the tabs (for example Tab1 has input1 and tab2 has input2 ) When i start the gui and type something in input1 on tab1 and then switch to tab2, the input on tab1 still has the focus (until i click input2 on tab2). This results in the problem, that when i type without first clicking on input2 the text is typed into input1 (but this happends hidden, i can not see it until i switch back to tab1). Is there a way to set the focus/active gui element when i change the tab? Thanks in advance for your ideas:-) cu allow Link to comment Share on other sites More sharing options...
PlayHD Posted January 4, 2013 Share Posted January 4, 2013 give us a short example of your script... My UDF : _WinShake, _WinSplitMy Apps : Google Guitar Bot, PuzzleGameDesign Gui : Interesting Tabs Design, RBox Project (abandoned), Animated Gui on Exit Link to comment Share on other sites More sharing options...
Allow2010 Posted January 4, 2013 Author Share Posted January 4, 2013 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TabConstants.au3> $hGUI = GUICreate("TestGUI", 300, 300) $hTab = GUICtrlCreateTab(10, 10, 280, 280) $tab1 = GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("input1", 20, 50, 150, 20) $input1 = GUICtrlCreateInput("", 20, 70, 250, 20) $tab2 = GUICtrlCreateTabItem("tab2") GUICtrlCreateLabel("input2", 20, 50, 150, 20) $input2 = GUICtrlCreateInput("", 20, 70, 250, 20) GUICtrlCreateTabItem("") GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd here it is. when you run the code do the following: 1. click into input1 in tab1 2. enter letters (aaaaaa) 3. click on tab2 (do not click into the input2 control, just type) 4. enter letters (bbbbbb) 5. click on tab1 the letters you typed in step 2 are now replaced by the lettery you typed in step 4 because the focus was still on the input1 control on tab1 even when i am on tab2. In my gui this often leads to the problem that a users changes values by mistake without noticing because those changes happen on a tab that is not visible Is there a way to know when a tab is clicked and then activate the first control on that tab? Edited January 4, 2013 by Allow2010 Link to comment Share on other sites More sharing options...
AZJIO Posted January 4, 2013 Share Posted January 4, 2013 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $tab Switch GUICtrlRead($tab) Case 1 ControlFocus($hWnd, "", "Edit2") Case 1 ControlFocus($hWnd, "", "Edit1") EndSwitch behdadsoft 1 My other projects or all Link to comment Share on other sites More sharing options...
Allow2010 Posted January 4, 2013 Author Share Posted January 4, 2013 #include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <TabConstants.au3>$hGUI = GUICreate("TestGUI", 300, 300)$hTab = GUICtrlCreateTab(10, 10, 280, 280)$tab1 = GUICtrlCreateTabItem("tab1")GUICtrlCreateLabel("input1", 20, 50, 150, 20)$input1 = GUICtrlCreateInput("", 20, 70, 250, 20)$tab2 = GUICtrlCreateTabItem("tab2")GUICtrlCreateLabel("input2", 20, 50, 150, 20)$input2 = GUICtrlCreateInput("", 20, 70, 250, 20)GUICtrlCreateTabItem("")GUISetState()While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hTab Switch GUICtrlRead($hTab) Case 0 GUICtrlSetState($input1, $GUI_FOCUS) Case 1 GUICtrlSetState($input2, $GUI_FOCUS) EndSwitch EndSwitchWEndWell the code from AZJIO brought me in the right directoion, so "Thank YOU" !But his code is not correct (Case 1 /Case 1). Also i think the use of ControLFocus is not optimal here... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 4, 2013 Moderators Share Posted January 4, 2013 Allow2010, Also i think the use of ControLFocus is not optimal here...You have to change the focus yourself - Windows does not as I showed here, although I used another strategy to change the keyboard focus. 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...
Allow2010 Posted January 4, 2013 Author Share Posted January 4, 2013 Thank you, i just wanted to say that GUICtrlSetState($input1, $GUI_FOCUS) is better when i am working with my own controls... ControLFocus is more for working with controls of existing programs 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