chinaboy Posted December 19, 2007 Share Posted December 19, 2007 expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> HotKeySet("{ENTER}","Jump") ;press "enter" will turn to next one inputbox GUICreate("My GUI Tab",700,500); will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Dim $Label[51][12] ;dim label array dim $Input[51][12] ;dim input array dim $array[51][12] ;for display and count all dim $tab_create[12] ;for create table items dim $tab_save_button[12] ;for create table items "save" buttons $t=1 ;new tabitem start number $tab=GUICtrlCreateTab (10,10,663,447) $New_TabItem=GUICtrlCreateButton ("NEW",10, 465,80,28) ;button for create new tabitem $COUNT_ALL=GUICtrlCreateButton ("COUNT ALL",100, 465,80,28);button for count all label data _create_TabItem($t) $t=$t+1 GUICtrlSetState($tab_create[$t],$GUI_SHOW) #comments-start $tab0=GUICtrlCreateTabitem ("tab0") GUICtrlSetState(-1,$GUI_SHOW); will be display first GUI_CREATE_LABEL_AND_INPUTBOX(1) $tab0_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) $tab1=GUICtrlCreateTabitem ( "tab1") GUI_CREATE_LABEL_AND_INPUTBOX(2) $tab1_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) $tab2=GUICtrlCreateTabitem ("tab2") GUI_CREATE_LABEL_AND_INPUTBOX(3) $tab2_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) ;GUICtrlCreateTabitem (""); end tabitem definition #comments-End GUISetState () ; Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg #comments-start CASE $tab0_OK $zz=1 display($zz) CASE $tab1_OK $zz=2 display($zz) CASE $tab2_OK $zz=3 display($zz) #comments-End CASE $tab_save_button[$t-1] $zz=$t-1 ;MsgBox(0,"",$zz) display($zz) CASE $COUNT_ALL _COUNT_DISPLAY_ALL() CASE $New_TabItem ;BUILD A NEW TabItem ; $tab3=GUICtrlCreateTabitem ("tab3") ;GUICtrlSetState(-1,$GUI_SHOW); will be display first ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _create_TabItem($t) $t=$t+1 GUICtrlSetState($tab_create[$t],$GUI_SHOW) ;;;;;;;;;;;;;;;;;;;;;;;;; Case $GUI_EVENT_CLOSE ;display() Exit EndSwitch WEnd func display($zz) ;read and show the data when press the 'SAVE' button for $z=1 to 50 $array[$z][$zz]=GUICtrlRead($Input[$z][$zz]) Next _ArrayDisplay($array,"") EndFunc func _GuiInputboxSetFont() GUICtrlSetLimit(-1,5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") EndFunc func _GuiSetFont() GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") EndFunc Func Jump() send("{Tab}") EndFunc FUNC GUI_CREATE_LABEL_AND_INPUTBOX($zz) $m=16 ;左上角定位 left position $n=123 ;列距 width between two units $y=5 ;列循环次数 $x=1 ;used for array ; ;LABEL for $k=1 to 5 For $j=1 to 10 $y=$y+40 $Label[$x][$zz] = GUICtrlCreateLabel($x, $m, $y, 40, 28, $SS_CENTER) _GuiSetFont() ;INPUTBOX $Input[$x][$zz] = GUICtrlCreateInput("", $m+52, $y, 57, 28,$ES_NUMBER) _GuiInputboxSetFont() $x=$x+1 Next $m=$m+$n ;change the position $y=5 ;reset the start line Next EndFunc FUNC _COUNT_DISPLAY_ALL() ;COUNT FOR ALL dim $array_all[51] ;array to cunt for all the same row dim $count_x $zz=1 for $count_x=1 to 50 $array_all[$count_x]=$array[$count_x][1]+$array[$count_x][2]+$array[$count_x][3] Next _ArrayDisplay($array_all) EndFunc func _create_TabItem($t) ;to create TabItems $tab_create[$t]=GUICtrlCreateTabItem($t) GUI_CREATE_LABEL_AND_INPUTBOX($t) ;GUICtrlSetState(-1,$GUI_SHOW) $tab_save_button[$t]=guictrlcreatebutton("SAVE",620,415,50,25) EndFunc well,when I press 'SAVE' frist,it's works,but when I pressed 'NEW' and then press 'SAVE' it don't works.and 'COUNT ALL' is always don't works. 'COUNT ALL' is used for sum all TabItem datas.The next one is what I want,but there is no "NEW" button expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> HotKeySet("{ENTER}","Jump") ;press "enter" will turn to next one inputbox GUICreate("My GUI Tab",700,500); will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Dim $Label[51][4] ;dim label array dim $Input[51][4] ;dim input array dim $array[51][4] ;for display and count all $tab=GUICtrlCreateTab (10,10,663,447) $COUNT_ALL=GUICtrlCreateButton ("COUNT ALL",10, 465,80,28) ;button for count all label data $tab0=GUICtrlCreateTabitem ("tab0") GUICtrlSetState(-1,$GUI_SHOW); will be display first GUI_CREATE_LABEL_AND_INPUTBOX(1) $tab0_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) $tab1=GUICtrlCreateTabitem ( "tab1") GUI_CREATE_LABEL_AND_INPUTBOX(2) $tab1_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) $tab2=GUICtrlCreateTabitem ("tab2") GUI_CREATE_LABEL_AND_INPUTBOX(3) $tab2_OK=GUICtrlCreateButton ("SAVE",620, 415,50,25) GUICtrlCreateTabitem (""); end tabitem definition GUISetState () ; Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg CASE $tab0_OK $zz=1 display($zz) CASE $tab1_OK $zz=2 display($zz) CASE $tab2_OK $zz=3 display($zz) CASE $COUNT_ALL _COUNT_DISPLAY_ALL() Case $GUI_EVENT_CLOSE ;display() Exit EndSwitch WEnd func display($zz) ;read and show the data when press the 'SAVE' button for $z=1 to 50 $array[$z][$zz]=GUICtrlRead($Input[$z][$zz]) Next _ArrayDisplay($array,"") EndFunc func _GuiInputboxSetFont() GUICtrlSetLimit(-1,5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") EndFunc func _GuiSetFont() GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") EndFunc Func Jump() send("{Tab}") EndFunc FUNC GUI_CREATE_LABEL_AND_INPUTBOX($zz) $m=16 ;左上角定位 left position $n=123 ;列距 width between two units $y=5 ;列循环次数 $x=1 ;used for array ; ;LABEL for $k=1 to 5 For $j=1 to 10 $y=$y+40 $Label[$x][$zz] = GUICtrlCreateLabel($x, $m, $y, 40, 28, $SS_CENTER) _GuiSetFont() ;INPUTBOX $Input[$x][$zz] = GUICtrlCreateInput("", $m+52, $y, 57, 28,$ES_NUMBER) _GuiInputboxSetFont() $x=$x+1 Next $m=$m+$n ;change the position $y=5 ;reset the start line Next EndFunc FUNC _COUNT_DISPLAY_ALL() ;COUNT FOR ALL dim $array_all[51] ;array to cunt for all the same row dim $count_x $zz=1 for $count_x=1 to 50 $array_all[$count_x]=$array[$count_x][1]+$array[$count_x][2]+$array[$count_x][3] Next _ArrayDisplay($array_all) EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted December 19, 2007 Share Posted December 19, 2007 Maybe... expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <GuiTab.au3> #include <File.au3> HotKeySet("{ENTER}", "Jump") ;press "enter" will turn to next one inputbox GUICreate("My GUI Tab", 700, 500); will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Dim $Label[12][51] ;dim label array Dim $Input[12][51] ;dim input array Dim $array[12][51] ;for display and count all Dim $tab_create[12] ;for create table items Dim $tab_save_button[12] ;for create table items "save" buttons Dim $t = 0 ;new tabitem start number $tab = GUICtrlCreateTab(10, 10, 663, 447) $New_TabItem = GUICtrlCreateButton("&NEW", 10, 465, 80, 28) ;button for create new tabitem $COUNT_ALL = GUICtrlCreateButton("&COUNT ALL", 100, 465, 80, 28);button for count all label data $Save_Button = GUICtrlCreateButton("&SAVE ALL", 190, 465, 80, 28);button for count all label data _create_TabItem() GUISetState() ; Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Save_Button _COUNT_DISPLAY_ALL(0) Case $COUNT_ALL _COUNT_DISPLAY_ALL(1) Case $New_TabItem ;BUILD A NEW TabItem _create_TabItem() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Jump() Send("{Tab}") EndFunc ;==>Jump Func GUI_CREATE_LABEL_AND_INPUTBOX($zz) $m = 16 ;????? left position $n = 123 ;?? width between two units $y = 5 ;????? $x = 1 ;used for array ;LABEL For $k = 1 To 5 For $j = 1 To 10 $y = $y + 40 $Label[$zz][$x] = GUICtrlCreateLabel($x, $m, $y, 40, 28, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") ;INPUTBOX $Input[$zz][$x] = GUICtrlCreateInput("", $m + 52, $y, 57, 28, $ES_NUMBER) GUICtrlSetLimit(-1, 5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $x = $x + 1 Next $m = $m + $n ;change the position $y = 5 ;reset the start line Next EndFunc ;==>GUI_CREATE_LABEL_AND_INPUTBOX Func _COUNT_DISPLAY_ALL($type = 1) ;COUNT FOR ALL $x = _GUICtrlTab_GetCurFocus ($tab) + 1 Local $array_all[51] ;array to cunt for all the same row Local $count_x Local $total = 0 For $count_x = 1 To UBound($array_all) - 1 $array_all[$count_x] = $count_x & " - " & GUICtrlRead($Input[$x][$count_x]) $total += Int(GUICtrlRead($Input[$x][$count_x])) Next $array_all[0] = $total If $type = 1 Then _ArrayDisplay($array_all) Else $Save_File = FileSaveDialog("Save File as", @ScriptDir, "Text files (*.txt)", 16 ) If @error <> 1 Then _FileWriteFromArray($Save_File, $array_all) EndIf EndFunc ;==>_COUNT_DISPLAY_ALL Func _create_TabItem() ;to create TabItems $t += 1 If $t >= (UBound($tab_create) - 1) Then MsgBox(0, "Sorry", "No more tabs are available", 3) Return EndIf $tab_create[$t] = GUICtrlCreateTabItem($t) GUI_CREATE_LABEL_AND_INPUTBOX($t) GUICtrlSetState($tab_create[$t], $GUI_SHOW) GUICtrlCreateTabItem(""); end tabitem definition EndFunc ;==>_create_TabItem 8) Link to comment Share on other sites More sharing options...
chinaboy Posted December 20, 2007 Author Share Posted December 20, 2007 Thank you for your help "Valuater" .There are so many good man in here. Link to comment Share on other sites More sharing options...
Valuater Posted December 20, 2007 Share Posted December 20, 2007 Welcome!! 8) 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