Sign in to follow this  
Followers 0
chachew

GUICtrlSetOnEvent for GUI load?

3 posts in this topic

Can i use GUICtrlSetOnEvent to call a function upon the loading of the GUI?

Im trying to run Func Check() upon the GUI loading but it doesnt seem to be working correctly, any thoughts?

.......
.....
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($Form1, "Check")

Func Check()
If FileExists("C:\cssnlogdir") = 1 Then
    $onCheck = 1
    GUICtrlSetData($lblStatus, "Running")
Else
    $onCheck = 0
    GUICtrlSetData($lblStatus, "Off")
EndIf
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnStart
            DirCreate("C:\cssnlogdir")
            GUICtrlSetData($lblStatus, "Running")
            GUICtrlSetFont($lblStatus, 11, 400, 0)
            GUICtrlSetColor($lblStatus, 0xC82536)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



mkirkland,

Ther is no suitable "event" when the GUI is created, so you cannot do it that way. As you are determining when the GUI is loaded, why not just call the function directly once you have created it? :mellow:

.......
.....
GUISetState(@SW_SHOW)
Check()

While
    [...]
WEnd

Func Check()
    [...]
EndFunc

You could always use WinWaitActive to ensure it is visible first if you so desired - although as it appears that you are setting a label within the GUI, I would run the function before the GUISetState so the GUI appeared with the label already set. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

...why not just call the function directly once you have created it? :mellow:

This worked just fine, thanks for the info, im a newb at Autoit so i didnt figure that out yet :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0