sunlord Posted February 10, 2007 Share Posted February 10, 2007 Anything wrong with this code? ;Rest of the code omitted $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem2 = GUICtrlCreateMenuItem("Settings", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem4 = GUICtrlCreateMenu("&About") GUICtrlSetState($From, $GUI_FOCUS) Guisetonevent($GUI_EVENT_CLOSE, "Exit2") GuiSetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem3 RunSmtp() EndSwitch WEnd My menu doesn't work. If I click "Settings" under "File" its supposed to run the RunSmtp() function but nothing happens? Link to comment Share on other sites More sharing options...
BALA Posted February 10, 2007 Share Posted February 10, 2007 (edited) Did this help? I aligned the Switch with the EndSwitch ;Rest of the code omitted $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem2 = GUICtrlCreateMenuItem("Settings", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem4 = GUICtrlCreateMenu("&About") GUICtrlSetState($From, $GUI_FOCUS) Guisetonevent($GUI_EVENT_CLOSE, "Exit2") GuiSetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem3 RunSmtp() EndSwitch WEnd Edited February 10, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 Nope......Same problem. Link to comment Share on other sites More sharing options...
BigDod Posted February 10, 2007 Share Posted February 10, 2007 Are you using GUISetOnEvent on the part of the script that we cant see. If so then GUIGetMsg and Switch will not work. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 I have these bits in the code. Do you mean one of them? Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent($Send, "RunSmtp") and Guisetonevent($GUI_EVENT_CLOSE, "Exit2") Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 ^ Link to comment Share on other sites More sharing options...
xcal Posted February 10, 2007 Share Posted February 10, 2007 Like BigDod said... "Are you using GUISetOnEvent on the part of the script that we cant see. If so then GUIGetMsg and Switch will not work."You don't mix GUISetOnEvent and GuiGetMsg. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 So are you saying I'm not supposed to have this bit in the code? Guisetonevent($GUI_EVENT_CLOSE, "Exit2") Just that bit or anything more? Link to comment Share on other sites More sharing options...
xcal Posted February 10, 2007 Share Posted February 10, 2007 When you have GUIOnEventMode set to 1 (on), you can't use GuiGetMsg(). It always returns 0. Instead, you can create functions with GuiSetOnEvent($control, 'function'). You have to choose to either use GuiGetMsg() method for gui events, or GuiSetOnEvent(). Which you use depends on whether you have GuiOnEventMode on or off. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 Ahhhh ok. Yeah I see what you mean. That works. Thanks. Link to comment Share on other sites More sharing options...
improbability_paradox Posted February 10, 2007 Share Posted February 10, 2007 (edited) something that seems to have been overlooked: $MenuItem3 is the item "Exit", as per your code. You need to check if the $nMsg=$MenuItem2 ("Settings") to do anything with that menu item when it is clicked!$MenuItem2 = GUICtrlCreateMenuItem("Settings", $MenuItem1)$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)Case $MenuItem3 RunSmtp() Edited February 10, 2007 by improbability_paradox Link to comment Share on other sites More sharing options...
sunlord Posted February 10, 2007 Author Share Posted February 10, 2007 I know , I was just testing if it actually works so I was just testing it with random functions in my script. 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