Jump to content

GUIOnEventMode


Recommended Posts

Hi all

I have added a Clickable link to my GUI using:

Opt("GUIOnEventMode",1)

$www = GUICtrlCreateLabel ("www.TheURL.com",528, 564, 130, 17)

GuiCtrlSetFont($www, 8.5, 800, 0, "MS Sans Serif")

GuiCtrlSetColor($www,0xA6CAF0)

GuiCtrlSetCursor($www,0)

GUICtrlSetOnEvent(-1, "OnWWW")

Func OnWWW()

Run(@ComSpec & " /c " & 'start www.TheURL.com/', "", @SW_HIDE)

EndFunc

After running i suddenly realised the Window Actions stoped working along with the dropdown menu id added

$filemenu = GUICtrlCreateMenu ("&File")

$save = GUICtrlCreateMenuitem ("Save",$filemenu)

$load = GUICtrlCreateMenuitem ("Load",$filemenu)

$msg = GUIGetMsg()

If $msg = $Save Then

If $msg = $Load Then

Looking through the help file i found this:

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

If the option GUIEventOptions is set to 1 the minimize, restore and maximize button will not do any action on the window just a simple notification.

How can i enable the clickable URL in my Gui and still have the Windows minimize, restore, maximize and my File/Save File/Load still work?

Link to comment
Share on other sites

OK - I'll try to sort somehow your post:

first: I guess you're confused about GUIOnEventMode

GUIOnEventMode Enable/disable OnEvent functions notifications.

0 = (default) disable.

1 = enable.

and

GUIEventOptions Change special event behavior or GUI function return values.

0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize.

1 = suppress windows behavior on minimize, restore or maximize click button or window resize. Just sends the notification

GUIEventOptions is not a must-have thing in your script - unless you want to (advice - avoid using it unless necessary).

Now I'll clean your script a lil'bit

Opt("GUIOnEventMode",1)

$www = GUICtrlCreateLabel ("www.TheURL.com",528, 564, 130, 17)
GUICtrlSetOnEvent(-1, "OnWWW")
GuiCtrlSetFont($www, 8.5, 800, 0, "MS Sans Serif")
GuiCtrlSetColor($www,0xA6CAF0)
GuiCtrlSetCursor($www,0)


While 1
   Sleep (100)
WEnd


Func OnWWW()
Run(@ComSpec & " /c " & 'start www.TheURL.com/', "", @SW_HIDE)
EndFunc

You can't use $msg = GUIGetMsg() here

Also pay attention to the need of a closing function (when you click the red-x button you have to tell the GUI what to do) - the help about GUIOnEventMode gives a great example.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Don't give up on a good opportunity to learn event mode:

#include <guiconstants.au3>

Opt("GUIOnEventMode",1)

$hGUI = GUICreate("Test", 400, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$filemenu = GUICtrlCreateMenu ("&File")
$save = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetOnEvent(-1, "FileMenu")
$load = GUICtrlCreateMenuitem ("Load",$filemenu)
GUICtrlSetOnEvent(-1, "FileMenu")
$www = GUICtrlCreateLabel ("www.TheURL.com",20, 20, 360, 30, $SS_CENTER)
GuiCtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GuiCtrlSetColor(-1,0xA6CAF0)
GuiCtrlSetCursor(-1,0)
GUICtrlSetOnEvent(-1, "OnWWW")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func OnWWW()
    $sExtCmd = @ComSpec & " /c " & 'start www.TheURL.com/'
    MsgBox(64, "WWW", "Would have run: " & $sExtCmd)
EndFunc

Func FileMenu()
    Switch @GUI_CtrlId
        Case $save
            MsgBox(64, "Save", "File/Save actions go here...")
        Case $load
            MsgBox(64, "Save", "File/Load actions go here...")
    EndSwitch
EndFunc

Never give up!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...