Jump to content

Thinking problem GUIMsg/OnEvent loop


Holger
 Share

Recommended Posts

Hi outthere o:)

I have a thinking/logical problem.

You know in the past it was possible to check if there is only a clicking/other GUI event in the queue with GUIMsg(0).

Now we don't have this anymore.

So, what I want to do?:

Yeah...I have a simple GUI with a button.

This button starts a procedure/function.

Now - this function is a recursive function like FileSearching.

So in this function I want to check if there is a clicking event.

But this is the problem!

If I use the OnEvent-mode then there is no message forwarding.

If I use the GUIGetMsg-loop I have after few seconds the internal 'sleep'-effect (cause there is no msg in the queue at this moment).

Does anybody knows you to get a GUI-message-event in a subfunction with using the OnEvent-mode?

I have absolutely no idea anymore :lmao:

Thanks

Holger

Link to comment
Share on other sites

@Alterego: thanks for answer.

But I have solved my thinking problem o:)

I have to use a function call for the "GuiOnEventMode" only for switching the process on and off and not for calling a subfunction.

Here is what I mean:

Opt("GUIOnEventMode",1)

#include <GUIConstants.au3>

Global $run = 0

GUICreate("test")
$label  = GUICtrlCreateLabel("",10,10,100,20)
$button = GUICtrlCreateButton("Start",10,50,70,20)
GUICtrlSetOnEvent(-1,"ButtonEvent")

GUISetState()

$i = 0
While 1
    Sleep(20)
    If $run = 1 Then
        $i = $i + 1
        GUICtrlSetData($label,$i)
    EndIf
WEnd

Exit

Func ButtonEvent()
    If $run = 0 Then
        $run = 1
    Else
        $run = 0
    EndIf
EndFunc

This is a very simple script but similar to mine.

So what I did first wrong was to call the GUICtrlSetData- and adding function in the "ButtonEvent" itself so this event was only fired 1 time and then never again before this function ended.

However :) now I know what I have to do :lmao:

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