xeroTechnologiesLLC Posted February 8, 2012 Share Posted February 8, 2012 (edited) Is there a way to verify what form as control when you click a button, or menu item, to load another gui form? I have a program that the load gui2 function was working perfectly fine last week before I made some additions to the way the menu dynamically resized (didn't change any of the form names or GUI calls), but now when I click the menu item to load gui2, the function runs to fill a tree view full of data but the form will not accept the close operations, esc key, clicking the X or clicking a button designed for close. Code I have tried so far: Case $GUI_EVENT_CLOSE, $hButton_Kill ExitLoop Case $GUI_EVENT_CLOSE, $hButton_Kill GUICtrlDelete($hGUI_Add) ExitLoop I even tried simply hiding it and not even exiting the loop, but that doesn't work either. My theory is that the control isn't being issued to the new window correctly. Or something else is happening I am just not familiar with, being extremely new to AutoIT. Any insight on the issue would be greatly appreciated. Below is the call for it: Case $MenuItem75, $MenuItem76, $MenuItem77, $MenuItem78, $MenuItem79, $MenuItem80, $MenuItem81, $MenuItem82, $MenuItem84, $menuitem88 GUISetState(@SW_DISABLE, $FRMtoolbox) _Add_User_Items("UserMenu") GUISetState(@SW_ENABLE, $FRMtoolbox) And the function itself, provided by Melba; edited for use for this project: expandcollapse popupFunc _Add_User_Items($sText) ; Create child GUI $hGUI_Add = GUICreate("Add Items", 400, 400, 50, -1, -1, $WS_EX_MDICHILD, $FRMtoolbox) ; Create a treeview GUICtrlCreateLabel("", 10, 10, 200, 380, $SS_BLACKFRAME) GUICtrlSetState(-1, $GUI_Enable) $hTreeView = GUICtrlCreateTreeView(20, 20, 180, 380);, $WS_BORDER) $hTV_Item = $hTreeView ; Fill the treeview with the menu structure _Fill_TV($hTreeView, $sText) ; Create other controls GUICtrlCreateLabel("Enter menu item text", 220, 10, 160, 20) $hInput_Item = GUICtrlCreateInput("", 220, 40, 160, 20) GUICtrlCreateLabel("Enter link", 220, 80, 160, 20) $hInput_Link = GUICtrlCreateInput("", 220, 100, 160, 20) $hButton_Addition = GUICtrlCreateButton("Add to menu", 310, 150, 80, 30) $hButton_Kill = GUICtrlCreateButton("Close", 310, 185, 80, 30) $nMsgAUItems = GUISetState() While 1 Switch $nMsgAUItems Case $GUI_EVENT_CLOSE, $hButton_Kill GUICtrlDelete($hGUI_Add) ExitLoop Case $hButton_Addition ; Do we have user input If GUICtrlRead($hInput_Item) <> "" And GUICtrlRead($hInput_Link) <> "" Then ; Read the selected menu from teh treeview $sSection = StringReplace(_GUICtrlTreeView_GetText($hTreeView, GUICtrlRead($hTreeView)), " ", "_") ; Get the item count $aItems = IniReadSection($sIni, $sSection) $iIndex = $aItems[0][0] + 1 ; Write the new item $sItem = StringReplace(GUICtrlRead($hInput_Item), " ", "_") IniWrite($sIni, $sSection, "Item" & $iIndex, $sItem) ; Write the link IniWrite($sIni, "Links", $sItem, GUICtrlRead($hInput_Link)) ; Delete GUI GUIDelete($hGUI_Add) ; Delete all the user menus For $i = $aUserItems[0] To $aUserItems[1] GUICtrlDelete($i) Next ; Reset menu $aUserItems = _Fill_Menu(0, "UserMenu") ExitLoop _GUICtrlMenu_DrawMenuBar($FRMtoolbox) EndIf EndSwitch WEnd EndFunc ;==>_Add_User_Items Thanks in advance for any points of view on the matter. As always, it is much appreciated. Edited April 7, 2012 by xeroTechnologiesLLC Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted February 8, 2012 Author Share Posted February 8, 2012 It seems that something is wrong in the While loop. I put in a message box on the first line before the while loop and the first line after. The one before - I could click ok and it would go away. The one after - I could click ok but nothing would happen. Thoughts? While 1 MsgBox(0, "", "win") ; <-- shows but unable to control. Switch $nMsgAUItems Case $GUI_EVENT_CLOSE, $hButton_Kill GUICtrlDelete($hGUI_Add) ExitLoop Case $hButton_Addition ; Do we have user input If GUICtrlRead($hInput_Item) <> "" And GUICtrlRead($hInput_Link) <> "" Then ; Read the selected menu from teh treeview $sSection = StringReplace(_GUICtrlTreeView_GetText($hTreeView, GUICtrlRead($hTreeView)), " ", "_") ; Get the item count $aItems = IniReadSection($sIni, $sSection) $iIndex = $aItems[0][0] + 1 ; Write the new item $sItem = StringReplace(GUICtrlRead($hInput_Item), " ", "_") IniWrite($sIni, $sSection, "Item" & $iIndex, $sItem) ; Write the link IniWrite($sIni, "Links", $sItem, GUICtrlRead($hInput_Link)) ExitLoop _GUICtrlMenu_DrawMenuBar($FRMtoolbox) EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted February 8, 2012 Author Share Posted February 8, 2012 So I figured out what the error was on the control of the GUI form: The following lines of code were just...wrong...above apparently: GUISetState(@SW_SHOW) While 1 $nMsgAUItems = GUIGetMsg() Switch $nMsgAUItems This inside the function. Next is to figure out why the main menu bar isn't refreshing the way it's supposed to based on this code: ; Delete all the user menus For $i = $aUserItems[0] To $aUserItems[1] GUICtrlDelete($i) Next ; Reset menu $aUserItems = _Fill_Menu(0, "UserMenu") 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