Jump to content

Quick question


sunlord
 Share

Recommended Posts

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

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 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

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

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.

Link to comment
Share on other sites

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 by improbability_paradox
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...