pdm Posted January 3, 2007 Share Posted January 3, 2007 Hello folks! When i start a little GUI-dialog and delete this afterwards, then the next created GUI will be screwed up. As far as i can see, all the elements are bigger than normal, only the form remains at the specified size. When i only hide the first GUI, then everything is ok with the second one. When i remove the menu from the second GUI, it will also work perfectly. The first dialog is only required once, therefore i want to get rid of it completely. Only hiding it, would bind resources. When you run the following code and select "Charly", the first GUI is deleted. In all other cases the GUI is only hidden. CODE #include <GUIList.au3> #include <GUIConstants.au3> Global $bt_end, $mn_exit, $form_tool Local $path = "c:\" Local $var_gui_color Opt ("MustDeclareVars", 1) Opt ("GUIOnEventMode", 0) main () func select_user ($username) local $a_users, $nMsg, $idx #Region ### START Koda GUI section ### Form=T:\_au3\select_user_gui.kxf Global $Form1 = GUICreate("Select Username", 261, 400, 197, 115, BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS)) Global $lbx_usernames = GUICtrlCreateList("", 16, 40, 241, 305, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) Global $Label1 = GUICtrlCreateLabel("Available Usernames", 16, 16, 139, 17) Global $bt_ok = GUICtrlCreateButton("OK", 176, 360, 81, 25, 0) Global $bt_abort = GUICtrlCreateButton("Abort", 16, 360, 81, 25, 0) ;Global $mn_file = GUICtrlCreateMenu("File") ;Global $mn_exit = GUICtrlCreateMenuItem("exit", $mn_file) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData ($lbx_usernames, "Charly") GUICtrlSetData ($lbx_usernames, "Mary") GUICtrlSetData ($lbx_usernames, "Bob") GUICtrlSetData ($lbx_usernames, "Rachel") _GUICtrlListSelectIndex ($lbx_usernames, 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $bt_abort $username = "default" ExitLoop Case $bt_ok $username = GUICtrlRead ($lbx_usernames) ExitLoop EndSwitch WEnd GUISetState(@SW_HIDE) ; Sleep(1000) if $username = "Charly" Then ;doing this GUIDelete() screws up the $form_tool-GUI which is displayed later. ;everything is displayed bigger as normal. ;it happens only when GUICtrlCreateMenu() is called. GUIDelete ($Form1) endif return $username EndFunc func _main_gui ($b_state) if $b_state Then #Region ### START Koda GUI section ### Form=T:\_au3\Tool_GUI.kxf Global $form_tool = GUICreate("DB-Tool", 964, 686, 191, 130) Global $bt_end = GUICtrlCreateButton("End", 888, 0, 72, 25) Global $Graphic1 = GUICtrlCreateGraphic(0, 24, 152, 632, 0) GUICtrlSetBkColor(-1, 0x008000) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) Global $lbl_hello = GUICtrlCreateLabel(" DB-Tool", 16, 32, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_hello, 0) Global $lbl_01 = GUICtrlCreateLabel("", 16, 56, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x800000) GUICtrlSetCursor ($lbl_01, 7) Global $lbl_02 = GUICtrlCreateLabel("", 16, 80, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_02, 0) Global $lbl_03 = GUICtrlCreateLabel("", 16, 104, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_03, 0) Global $mn_file = GUICtrlCreateMenu("&File") Global $mn_exit = GUICtrlCreateMenuItem("exit", $mn_file) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Else ;GUISetState (@SW_HIDE) GUIDelete ($form_tool) EndIf EndFunc func main () local $user, $ini_file, $msg, $starter $user = @UserName if $user = "Administrator" or $user = "admin" Then $user = select_user ($user) EndIf $ini_file = IniRead ($Path & "UserList.ini", "Usernames", $user, $Path & "default.ini") $var_gui_color = number (IniRead ($ini_file, "GUI", "farbe", "0xff5ece")) _main_gui (True) ; msgbox (0, "db-tool", "Ini-File="& $ini_file &" Color="& $var_gui_color) while 1 $msg = GUIGetMsg () Switch $msg case $bt_end, $mn_exit, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _main_gui (False) EndFunc PS: In my original source, i'm using included files to create the GUIs via Koda. Here i copied only the most relevant code into one block. Link to comment Share on other sites More sharing options...
Valuater Posted January 3, 2007 Share Posted January 3, 2007 (edited) ALWAYS>>>>> create the menu first Global $form_tool = GUICreate("DB-Tool", 964, 686, 191, 130) Global $mn_file = GUICtrlCreateMenu("&File") Global $mn_exit = GUICtrlCreateMenuitem("exit", $mn_file) then other controls.... if using a menu 8) Edited January 3, 2007 by Valuater Link to comment Share on other sites More sharing options...
pdm Posted January 4, 2007 Author Share Posted January 4, 2007 ALWAYS>>>>> create the menu first Global $form_tool = GUICreate("DB-Tool", 964, 686, 191, 130) Global $mn_file = GUICtrlCreateMenu("&File") Global $mn_exit = GUICtrlCreateMenuitem("exit", $mn_file) then other controls.... if using a menu 8)Thank you for this valuable hint, Valuater! I don't see why this is a must. It looks more like a bug. It seems that KoDa doesn't know this rule either. Although the menu is always the first element in the tree, the code is generated at the end. If the menu must 'ALWAYS' be created first, i cannot use KoDa anymore. But i don't want to code the GUI by hand. Is there any other workaround? When i create and delete the second GUI and create it a second time, then everything looks fine. I only have to remove the automatically generated GUISetState(@SW_SHOW)-statement after a script-update from KoDa. The updated example shows this: expandcollapse popup#include <GUIList.au3> #include <GUIConstants.au3> Global $bt_end, $mn_exit, $form_tool Local $path = "c:\" Local $var_gui_color Opt ("MustDeclareVars", 1) Opt ("GUIOnEventMode", 0) main () func select_user ($username) local $a_users, $nMsg, $idx #Region ### START Koda GUI section ### Form=T:\_au3\select_user_gui.kxf Global $Form1 = GUICreate("Select Username", 261, 400, 197, 115, BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS)) Global $lbx_usernames = GUICtrlCreateList("", 16, 40, 241, 305, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) Global $Label1 = GUICtrlCreateLabel("Available Usernames", 16, 16, 139, 17) Global $bt_ok = GUICtrlCreateButton("OK", 176, 360, 81, 25, 0) Global $bt_abort = GUICtrlCreateButton("Abort", 16, 360, 81, 25, 0) ;Global $mn_file = GUICtrlCreateMenu("File") ;Global $mn_exit = GUICtrlCreateMenuItem("exit", $mn_file) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData ($lbx_usernames, "Charly") GUICtrlSetData ($lbx_usernames, "Mary") GUICtrlSetData ($lbx_usernames, "Bob") GUICtrlSetData ($lbx_usernames, "Rachel") _GUICtrlListSelectIndex ($lbx_usernames, 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $bt_abort $username = "default" ExitLoop Case $bt_ok $username = GUICtrlRead ($lbx_usernames) ExitLoop EndSwitch WEnd GUISetState(@SW_HIDE) ; Sleep(1000) if $username = "Charly" Then ;doing this GUIDelete() screws up the $form_tool-GUI which is displayed later. ;everything is displayed bigger as normal. ;it happens only when GUICtrlCreateMenu() is called. GUIDelete ($Form1) endif return $username EndFunc func _main_gui ($b_state, $b_show) if $b_state Then #Region ### START Koda GUI section ### Form=T:\_au3\Tool_GUI.kxf Global $form_tool = GUICreate("DB-Tool", 964, 686, 191, 130) Global $bt_end = GUICtrlCreateButton("End", 888, 0, 72, 25) Global $Graphic1 = GUICtrlCreateGraphic(0, 24, 152, 632, 0) GUICtrlSetBkColor(-1, 0x008000) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) Global $lbl_hello = GUICtrlCreateLabel(" DB-Tool", 16, 32, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_hello, 0) Global $lbl_01 = GUICtrlCreateLabel("", 16, 56, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x800000) GUICtrlSetCursor ($lbl_01, 7) Global $lbl_02 = GUICtrlCreateLabel("", 16, 80, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_02, 0) Global $lbl_03 = GUICtrlCreateLabel("", 16, 104, 136, 23, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor ($lbl_03, 0) Global $mn_file = GUICtrlCreateMenu("&File") Global $mn_exit = GUICtrlCreateMenuItem("exit", $mn_file) ;GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### if $b_show Then GUISetState(@SW_SHOW) EndIf Else ;GUISetState (@SW_HIDE) GUIDelete ($form_tool) EndIf EndFunc func main () local $user, $ini_file, $msg, $starter $user = @UserName ; if $user = "Administrator" or $user = "admin" Then ;for testing this should apply to every username $user = select_user ($user) ; EndIf $ini_file = IniRead ($Path & "UserList.ini", "Usernames", $user, $Path & "default.ini") $var_gui_color = number (IniRead ($ini_file, "GUI", "farbe", "0xff5ece")) _main_gui (True ,False) ;create it hidden _main_gui (False, False) ;and remove it again _main_gui (True, True) ;and create it again ; msgbox (0, "db-tool", "Ini-File="& $ini_file &" Color="& $var_gui_color) while 1 $msg = GUIGetMsg () Switch $msg case $bt_end, $mn_exit, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _main_gui (False, False) EndFunc PS: I'm using AutoIt 3.2.1.13 (beta) and KoDa 1.6.0.2 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