PantZ4 Posted October 13, 2007 Share Posted October 13, 2007 Seems that GUI and I just wont go hand in hand . If you try press on the tab called "Create new tab", it will create a new tab. But for some reason it wont create the edit control... every second time. Try press it again. Now you got 4 tabs. "New Tab 1", "New Tab 2", "New Tab 2" and "Create New Tab". The "New Tab 1" will have a edit control and the same with the second "New Tab 2", yet the first "New Tab 2" have not! Can anyone one tell me why? Thanks. expandcollapse popup#include <GUIConstants.au3> #include <GUIEdit.au3> #include <Misc.au3> #include <GuiTab.au3> $GUIWIDTH = 546 $GUIHEIGHT = 394 Local $GUIStatusBarPartLenght[3] = [320, 415, 545] Local $GUIStatusBarPartText[3] = ["Waiting for command...", "Press F1 for help", "Donate to AutoIt!"] $GUI = GUICreate("My Program",$GUIWIDTH,$GUIHEIGHT,-1,-1,$WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX) GUIRegisterMsg(0x24, "_GUISetResizing") GUICtrlCreateMenu("&File") GUICtrlCreateMenu("&Edit") GUICtrlCreateMenu("&View") GUICtrlCreateMenu("&Help") $GUIStatusBar = _GUICtrlStatusBarCreate ($GUI, $GUIStatusBarPartLenght, $GUIStatusBarPartText) ;_GUICtrlStatusBarSetIcon($GUIStatusBar, 2, "C:\Documents and Settings\****\Skrivebord\donate.ico",0) GUICtrlCreateInput("",34,48,$GUIWIDTH-232,25) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKHEIGHT) GUICtrlCreateButton("Waiting for command",$GUIWIDTH-190,48,180,25) GUICtrlSetResizing(-1,$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlSetState(-1,$GUI_DISABLE) $GUITabControl = GUICtrlCreateTab(-5,79,$GUIWIDTH+10,$GUIHEIGHT-145,$TCS_FIXEDWIDTH) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUICtrlCreateTabItem("New Tab 1") GUICtrlCreateEdit("asda",-2,100,$GUIWIDTH+2,$GUIHEIGHT-170,$ES_MULTILINE+$ES_READONLY+$WS_VSCROLL) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) $GUITabItemControlCreateNewTab = GUICtrlCreateTabItem("Create New Tab") GUISetState() While 1 $a_GUISize = WinGetPos($GUI) $a_MousePos = MouseGetPos() If $a_MousePos[0] >= ($a_GUISize[0]+($a_GUISize[2]-130)) And $a_MousePos[0] <= ($a_GUISize[0]+($a_GUISize[2]-25)) And $a_MousePos[1] >= $a_GUISize[1]+$a_GUISize[3]-25 And $a_MousePos[1] <= $a_GUISize[1]+$a_GUISize[3]-5 Then GUISetCursor(0,1,$GUI) If _IsPressed(01) = 1 And WinActive($GUI) = 1 Then ShellExecute("http://www.autoitscript.com/donate.php") Sleep(1000) EndIf ElseIf MouseGetCursor() = 0 Then GUISetCursor(2,0,$GUI) EndIf If _GUICtrlTabGetCurSel($GUITabControl) = (_GUICtrlTabGetItemCount($GUITabControl)-1) Then _GUICtrlTabDeleteItem($GUITabControl,(_GUICtrlTabGetItemCount($GUITabControl)-1)) GUICtrlCreateTabItem("New Tab 2") GUICtrlCreateEdit("Random",-2,100,$a_GUISize[2]-4,$a_GUISize[3]-176,$ES_MULTILINE+$ES_READONLY+$WS_VSCROLL) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) $GUITabItemControlCreateNewTab = GUICtrlCreateTabItem("Create New Tab") EndIf $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE $GUIStatusBarPartLenght[0] = $a_GUISize[2]-230 $GUIStatusBarPartLenght[1] = $a_GUISize[2]-135 $GUIStatusBarPartLenght[2] = -1 _GUICtrlStatusBarSetParts($GUI, $GUIStatusBar, 3, $GUIStatusBarPartLenght) _GUICtrlStatusBarResize ($GUIStatusBar) EndSelect Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Sleep(10) WEnd Func _GUISetResizing($hWnd, $Msg, $wParam, $lParam) $dllstruct = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam) DllStructSetData($dllstruct,7,552) DllStructSetData($dllstruct,8,400) Return 0 EndFunc Link to comment Share on other sites More sharing options...
martin Posted October 13, 2007 Share Posted October 13, 2007 (edited) Seems that GUI and I just wont go hand in hand . If you try press on the tab called "Create new tab", it will create a new tab. But for some reason it wont create the edit control... every second time. Try press it again. Now you got 4 tabs. "New Tab 1", "New Tab 2", "New Tab 2" and "Create New Tab". The "New Tab 1" will have a edit control and the same with the second "New Tab 2", yet the first "New Tab 2" have not! Can anyone one tell me why? Thanks. Can't really say, but to me it seems like a strange idea to use a tab for a button and to keep destroying then creating it. I would do something more like this- expandcollapse popup#include <GUIConstants.au3> #include <GUIEdit.au3> #include <Misc.au3> #include <GuiTab.au3> $GUIWIDTH = 546 $GUIHEIGHT = 394 Global $tabcount = 0,$tabtabs[30] Local $GUIStatusBarPartLenght[3] = [320, 415, 545] Local $GUIStatusBarPartText[3] = ["Waiting for command...", "Press F1 for help", "Donate to AutoIt!"] $GUI = GUICreate("My Program",$GUIWIDTH,$GUIHEIGHT,-1,-1,$WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX) GUIRegisterMsg(0x24, "_GUISetResizing") $AddTab = guictrlcreatebutton("add Tab",20,2,80,21) GUICtrlCreateMenu("&File") GUICtrlCreateMenu("&Edit") GUICtrlCreateMenu("&View") GUICtrlCreateMenu("&Help") $GUIStatusBar = _GUICtrlStatusBarCreate ($GUI, $GUIStatusBarPartLenght, $GUIStatusBarPartText) ;_GUICtrlStatusBarSetIcon($GUIStatusBar, 2, "C:\Documents and Settings\****\Skrivebord\donate.ico",0) GUICtrlCreateInput("",34,48,$GUIWIDTH-232,25) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKHEIGHT) GUICtrlCreateButton("Waiting for command",$GUIWIDTH-190,48,180,25) GUICtrlSetResizing(-1,$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlSetState(-1,$GUI_DISABLE) $GUITabControl = GUICtrlCreateTab(-5,79,$GUIWIDTH+10,$GUIHEIGHT-145,$TCS_FIXEDWIDTH) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) $tabtabs[0] = GUICtrlCreateTabItem("New Tab 1") GUICtrlCreateEdit("asda",-2,100,$GUIWIDTH+2,$GUIHEIGHT-170,$ES_MULTILINE+$ES_READONLY+$WS_VSCROLL) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) ;$GUITabItemControlCreateNewTab = GUICtrlCreateTabItem("Create New Tab") GUICtrlCreateTabitem ("") ; end tabitem definition GUISetState() $tabcount = 1 While 1 $a_GUISize = WinGetPos($GUI) $a_MousePos = MouseGetPos() If $a_MousePos[0] >= ($a_GUISize[0]+($a_GUISize[2]-130)) And $a_MousePos[0] <= ($a_GUISize[0]+($a_GUISize[2]-25)) And $a_MousePos[1] >= $a_GUISize[1]+$a_GUISize[3]-25 And $a_MousePos[1] <= $a_GUISize[1]+$a_GUISize[3]-5 Then GUISetCursor(0,1,$GUI) If _IsPressed(01) = 1 And WinActive($GUI) = 1 Then ShellExecute("http://www.autoitscript.com/donate.php") Sleep(1000) EndIf ElseIf MouseGetCursor() = 0 Then GUISetCursor(2,0,$GUI) EndIf $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE $GUIStatusBarPartLenght[0] = $a_GUISize[2]-230 $GUIStatusBarPartLenght[1] = $a_GUISize[2]-135 $GUIStatusBarPartLenght[2] = -1 _GUICtrlStatusBarSetParts($GUI, $GUIStatusBar, 3, $GUIStatusBarPartLenght) _GUICtrlStatusBarResize ($GUIStatusBar) case $msg = $addtab $tabcount += 1 $tabtabs[$tabcount - 1] = GUICtrlCreateTabItem("New Tab " & $tabcount) GUISwitch($Gui,$tabtabs[$tabcount - 1]) GUICtrlCreateEdit("Random " & $tabcount,30,100 + $tabcount * 20,$a_GUISize[2]-12,$a_GUISize[3]-176,$ES_MULTILINE+$ES_READONLY+$WS_VSCROLL) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUICtrlCreateTabItem("") Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Sleep(10) WEnd Func _GUISetResizing($hWnd, $Msg, $wParam, $lParam) $dllstruct = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam) DllStructSetData($dllstruct,7,552) DllStructSetData($dllstruct,8,400) Return 0 endfunc EDIT:Removed a mistake Edited October 13, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PantZ4 Posted October 13, 2007 Author Share Posted October 13, 2007 Your idea is good enough, but I really want it to be though the tab control, since I'm going to use most of the GUI. I just can't understand why it does not create the edit control, in the right tab. But still thanks martin . 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