eyegeegeewhy Posted February 19, 2008 Share Posted February 19, 2008 Hi Im struggling with this parent child window thing. Could someone in the know who has a few spare minutes make me an example I can work from. What I want is a gui with a main menu at the top that when selected open up new windows with a msgbox button on it (this should be in a function). Im not asking people to do work for me just a really simple example that I can chenge and edit to understand what is going on. From the searches I have done on parent/child windoes im sure other pople would find this helpful. Any help would be greatly appreciated. Cheers Jord Link to comment Share on other sites More sharing options...
botanic Posted February 19, 2008 Share Posted February 19, 2008 Look in the helpfile under guictrlcrreatemenu and this script is at the bottom just FYI the helpfile for autoit is good use it expandcollapse popup#include <GUIConstants.au3> GUICreate("My GUI menu",300,200) Global $defaultstatus = "Ready" Global $status $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) GUICtrlSetState(-1,$GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu ("?") $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu) GUICtrlSetState(-1,$GUI_DISABLE) $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu) $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu) $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1) $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu) GUICtrlSetState(-1,$GUI_CHECKED) $okbutton = GUICtrlCreateButton ("OK",50,130,70,20) GUICtrlSetState(-1,$GUI_FOCUS) $cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20) $statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN)) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)") If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu) EndIf If $msg = $viewstatusitem Then If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED) GUICtrlSetState($statuslabel,$GUI_HIDE) Else GUICtrlSetState($viewstatusitem,$GUI_CHECKED) GUICtrlSetState($statuslabel,$GUI_SHOW) EndIf EndIf If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then Msgbox(0,"Info","Only a test...") WEnd GUIDelete() Exit Link to comment Share on other sites More sharing options...
newbiescripter Posted February 19, 2008 Share Posted February 19, 2008 Go to: SciTE - Tools - Koda(Form Designer) It's a great start and very easy! Link to comment Share on other sites More sharing options...
eyegeegeewhy Posted February 19, 2008 Author Share Posted February 19, 2008 I use the autoit help file quite a lot. The issue i think im having is not the creation/layout of the gui. its more to do with parent/child windows and buttons/objects on the child windows. The helpfile is usually great but I think the referance material for this section is quite weak. Either the code is only for window functions (close etc) or it is very specific to one extra window and not very generic on how you could adapt it for more children. Link to comment Share on other sites More sharing options...
botanic Posted February 19, 2008 Share Posted February 19, 2008 (edited) Ok if you want multipul buttons just do like this expandcollapse popupglobal $msg, $num, $1, $2 #include <C:\Program Files\AutoIt3\Include\GUIConstants.au3> #NoTrayIcon GUICreate("Azeureus?", 150, 80) $label = GUICtrlCreateLabel("Azeureus will autorun in 30", 10, 0) $Button_1 = GUICtrlCreateButton ("Run", 10, 20, 60) $Button_2 = GUICtrlCreateButton ("Stop", 80, 20, 60) $Button_3 = GUICtrlCreateButton ("Wait and Run", 10, 50, 130) GUISetState() $num = 30 $2= 3 While 1 if $num <> 123 then GUICtrlSetData($label, "Azeureus will autorun in " & $num) Else if $2 = 2 then GUICtrlSetData($label, " Waiting...") $2 = 0 ElseIf $2 = 1 then GUICtrlSetData($label, " Waiting..") $2 = 2 ElseIf $2 = 0 then GUICtrlSetData($label, " Waiting.") $2 = 1 EndIf EndIf For $1 = 0 to 10 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Run("C:\Program Files\Azureus\Azureus.exe") Exit Case $msg = $Button_1 Run("C:\Program Files\Azureus\Azureus.exe") Exit Case $msg = $Button_2 Exit Case $msg = $Button_3 GUICtrlSetData($label, " Waiting...") $num = 123 $2 = 0 EndSelect sleep(100) Next if $num <> 123 Then $num = $num -1 EndIf if $num = -1 then Run("C:\Program Files\Azureus\Azureus.exe") Exit WendoÝ÷ Øô¤¡Ö¢±·¥ëÞÊ'(§¶ºYlr+^½êìÄÚØÊ°j{m¢¬²ö«¦åzǶ;¬¶«±ëazka® §îËb¢z+ºÇZjV®¶sb6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC° ¤uT7&VFRgV÷C´×uT'WGFöâgV÷C²²vÆÂ7&VFRFÆör&÷FBvVâF7ÆVB26VçFW&V@ ¤÷BgV÷C´uT6ö÷&DÖöFRgV÷C²Ã"¢b33c´'WGFöåóÒuT7G&Ä7&VFT'WGFöâgV÷Cµ'Vâæ÷FWBgV÷C²ÂÂ3¢b33c´'WGFöåó"ÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöâFW7BgV÷C²ÂÂÓ ¤uT6WE7FFR²vÆÂF7ÆâFÆör&÷vF"'WGFöà £²'VâFRuTVçFÂFRFÆör26Æ÷6V@ ¦gVæ2ö§&WGW&âgV÷C¶VÆÆògV÷C°¦VæFgVæ0 ¥vÆR¢b33c¶×6rÒuTvWD×6r¢6VÆV7@¢66Rb33c¶×6rÒb33c´uTôUdTåEô4Äõ4P¢WDÆö÷¢66Rb33c¶×6rÒb33c´'WGFöåó¢×6t&÷Âb33µFW7Færb33²Âö²vÆÂFVÖöç7G&FR'WGFöâ&Vær&W76V@¢66Rb33c¶×6rÒb33c´'WGFöåó ¢×6t&÷Âb33µFW7Færb33²Âb33´'WGFöâ"v2&W76VBb33²²vÆÂFVÖöç7G&FR'WGFöâ"&Vær&W76V@¢VæE6VÆV7@¥vVæ@ Edited February 19, 2008 by botanic Link to comment Share on other sites More sharing options...
ReFran Posted February 20, 2008 Share Posted February 20, 2008 That's the way I do It. Attached a general, simple GUI with SubGui (in a own function) example. HTH, Reinhard expandcollapse popup#include <GUIConstants.au3> DIM $SubGUI DIM $LvDatNew = "" GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES) GUISetBkColor (0x00E0FFFF) ; will change background color $listview = GuiCtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING) $button = GuiCtrlCreateButton ("Edit?",75,170,70,20) $item1=GuiCtrlCreateListViewItem("item1|col12|col13",$listview) $item2=GuiCtrlCreateListViewItem("item2|col22|col23",$listview) $item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview) $input1=GuiCtrlCreateInput("",20,200, 150) GuiCtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and dropping GuiSetState() Do $msg = GuiGetMsg () Select Case $msg = $button $itemAc = GUICtrlRead($listview) $Lvdat = GUICtrlRead($iTemAc) SubGui($Lvdat) if $lvDatnew <> "" then GuiCtrlSetData($itemAc,$lvdatnew) Case $msg = $listview MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2) EndSelect Until $msg = $GUI_EVENT_CLOSE func SubGUI($LvDat) $SubGUI = GUICreate(" Edit Listview",350,130) $aLvDat = stringSplit($lvDat,"|") $Inp1 = GUICtrlCreateInput ($aLvDat[1], 10, 5, 300, 20) $inp2 = GUICtrlCreateInput ($aLvDat[2], 10, 35, 300, 20) ; will not accept drag&drop files $inp3 = GUICtrlCreateInput ($aLvDat[3], 10, 65, 300, 20) $btn_OK = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () $msgSub = 0 While $msgSub <> $GUI_EVENT_CLOSE $msgSub = GUIGetMsg() if $msgSub = $btn_OK then $LvDatNew = GUICtrlRead($inp1)&"|"&GUICtrlRead($inp2)&"|"&GUICtrlRead($inp3) exitLoop endif Wend GUIDelete($SubGUI) EndFunc 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