mikeyr Posted January 29, 2008 Share Posted January 29, 2008 (edited) I have just discovered AutoIT this morning and already created some very simple apps to make my life easier, but the more complicated one is getting to me I have a app that opens up 8 tabs and writes to specific tabs based on what it finds in the MySQL database and also after creation, I will have buttons to move data from one tab to the other, thought it would be simple but I am not sure how to do it. Searching I found that I could do this (it did work when I tried it)CODE $hTab = GUICtrlCreateTab(2, 2, 396, 296) GUISetState() ; Add tabs $tab0 = _GUICtrlTab_InsertItem ($hTab, 0, "Main Tab") $tab1 = _GUICtrlTab_InsertItem ($hTab, 1, "Tab 1") $tab2 = _GUICtrlTab_InsertItem ($hTab, 2, "Tab 2") $tab3 = _GUICtrlTab_InsertItem ($hTab, 3, "Tab 3") $tab0 = GUICtrlCreateLabel ("Here in the main tab", 10, 30, 500) $tab1 = GUICtrlCreateLabel ("Here in Tab 1", 10, 30, 500) But in my code because I am dealing with 8 tabs, what I did instead was CODE $tabs = GuiCtrlCreateTab(5, 3, 640, 480) For $i = 0 to $NUM_OF_LOCATIONS - 1 $tabs[$i]= GuiCtrlCreateTabItem($NAMES[$i]) Next GUICtrlCreateTabItem("") _GUICtrlTab_SetCurFocus ($tabs,0) $tabs[0] = GUICtrlCreateLabel ("Here", 10, 30, 500) ; GuiSetState() That will NOT work, if I remove the $tabs[] then it properly creates the 8 tabs but it writes to all 8 tabs. I believe I understand what is going on, I don't have a handle to the individual tabs so I can't play with the individual tabs. By taking out the for loop I can create the tabs with a handle but it gets messy when dealing with 8 tabs. What I would really like to is inside the FOR loop when I create the tabs is name them so I can then do "name = GUICtrlCreateLable(bla...) later in my code. OR I am doing this completely wrong (wont be the first time I complicated things). Mike ***edit*** my first example is not working either, it had to do with the order I was playing with, so maybe a handle is not what I need. Do I need to first set the current tab before writing to it ? I see SetState ... Edited January 29, 2008 by mikeyr Link to comment Share on other sites More sharing options...
mikeyr Posted January 30, 2008 Author Share Posted January 30, 2008 (edited) Darn, I can't edit the above one anymore... OK, I found something that works, not the way I want but it works. From the AutoIT examples CODE $tab0 = _GUICtrlTab_InsertItem ($hTab, 0, "Tab 1") $tab1 = _GUICtrlTab_InsertItem ($hTab, 1, "Tab 2") $tab2 = _GUICtrlTab_InsertItem ($hTab, 2, "Tab 3") ; Get/Set current focus _GUICtrlTab_SetCurFocus ($hTab, $tab1) GUICtrlCreateLabel ("Here", 10, 30, 500)That SetCurFocus allows me to write to the tab I want. What I really want to do however is that InsertItem in a loop for example : for $i = 0 to $var $tabs[$i] = ..InstertItem($htab, $i, $NAMES[$i] next Then HOPEFULLY I can do $tabs[1] = createlabel.... Is this possible somehow, I know the syntax I am using wont work but hopefully you get the idea That way I can change the number of tabs in the future easy and I can access my tabs via some var like $tab0, I know the $tab$i wont work, but I hope you get the idea of what I am trying to do. Edited January 30, 2008 by mikeyr Link to comment Share on other sites More sharing options...
mikeyr Posted January 30, 2008 Author Share Posted January 30, 2008 GOT IT !!! might be a bug, most likely I am doing something very wrong, but I got it. My problem was that I was trying to set values on tab 0 and it would write on all the tabs as if tab 0 did not exist, the workaround is to SetCurFocus to another tab and SetCurFocus to 0. I had it working all along except for that. Here is the code I took from the examples and you can see the second section is a cut/paste of the first section except for the extra SetCurFocus CODE#include <GuiConstantsEx.au3> #include <GuiTab.au3> Local $hGUI, $hTab Local $tabs[3] ; Create GUI GUICreate("(Internal) Tab Control Set Current Focus", 400, 300) $hTab = GUICtrlCreateTab(2, 2, 396, 296) GUISetState() ; Add tabs for $i = 0 to 2 $tabs[$i] = _GUICtrlTab_InsertItem ($hTab, $i, "Tab " & $i) Next ; Get/Set current focus _GUICtrlTab_SetCurFocus ($hTab, $tabs[0]) GUICtrlCreateLabel ("Should NOT see this on all 3 tabs, but you do", 10, 30, 500) _GUICtrlTab_SetCurFocus ($hTab, $tabs[0]) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ; Create GUI GUICreate("(Internal) Tab Control Set Current Focus", 400, 300) $hTab = GUICtrlCreateTab(2, 2, 396, 296) GUISetState() ; Add tabs for $i = 0 to 2 $tabs[$i] = _GUICtrlTab_InsertItem ($hTab, $i, "Tab " & $i) Next ; Get/Set current focus _GUICtrlTab_SetCurFocus ($hTab, $tabs[1]) ; SET IT to SOMETHING ELSE besides 0 and then 0 _GUICtrlTab_SetCurFocus ($hTab, $tabs[0]) GUICtrlCreateLabel ("This works because I first focused on $tabs[1] in the code.", 10, 30, 500) _GUICtrlTab_SetCurFocus ($hTab, $tabs[0]) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() 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