From: <se...@la...> - 2001-06-26 23:33:18
|
IN the documentation, I find this about DoEvents: Just like Dialog(), but returns when there are no more events to process. So does that mean that if you leave your window alone, control will return to the script? So to keep your script from exiting as soon as you stop clicking buttons, etc. you'd have to do something like this: $keep_running = 1; Win32::GUI::DoEvents while ($keep_running); and then do something in one of your events that changes $keep_running. So wouldn't it be easier just to use Dialog and have that event return -1? I guess what I'm really asking here is, what are the pros and cons of DoEvents over Dialog? And if someone could provide an example of a script that uses DoEvents, that would be good. |
From: Glenn L. <Gle...@ne...> - 2001-06-26 23:50:41
|
Useful for the case when you want to do things that are not window driven, and don't want to fork them into a separate process. Then the GUI becomes less responsive (because you are doing something else sometimes), but, as long as the chunks of something else are not too big, it need not become too unresponsive. So then you can interrupt your things that are not window driven to respond to the user's events. $keep_running = 1; while ($keep_running) { Win32::GUI::DoEvents; do something_else; } se...@la... wrote: > IN the documentation, I find this about DoEvents: > > Just like Dialog(), but returns when there are no more events to > process. > > So does that mean that if you leave your window alone, control will > return to the script? So to keep your script from exiting as soon as > you stop clicking buttons, etc. you'd have to do something like this: > > $keep_running = 1; > > Win32::GUI::DoEvents while ($keep_running); > > and then do something in one of your events that changes > $keep_running. So wouldn't it be easier just to use Dialog and have > that event return -1? I guess what I'm really asking here is, what > are the pros and cons of DoEvents over Dialog? And if someone could > provide an example of a script that uses DoEvents, that would be > good. > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Johan L. <jo...@ba...> - 2001-06-26 23:59:03
|
Sean wrote: >$keep_running. So wouldn't it be easier just to use Dialog and have >that event return -1? In most cases, yes. I would guess that Dialog() is a tighter and more efficient loop than you can roll on your own in Perl. What Dialog and DoEvents actually do is this: they process GUI messages that makes the window respond to things the user does, like moving focus, animating buttons as you click them, etc. If you use neither of these subs, the window will be visible but totally "dead". When the Dialog message loop triggers an event, e.g. btnUploadFile_Click, the control moves from this GUI message processing into your event handler. From now on, your code is executing, not the code keeping the GUI responsive to the user. So what if you have to do a _lot_ of stuff before you can return from the event handler? In this case, your code is executing for a long time, the GUI message code isn't executing at all; the GUI is "dead". This is where you call DoEvents() to give the GUI a chance to handle messages and respond to user interaction every once in a while. Do this "as often as possible" to give the impression that the GUI is always listening to user interaction. BTW, most of this has been said before a few times. Browse the archives for more info. /J ------ ---- --- -- -- -- - - - - - Johan Lindström Boss Casinos Sourcerer jo...@ba... http://www.bahnhof.se/~johanl/ If the only tool you have is a hammer, everything tends to look like a nail |
From: <se...@la...> - 2001-06-27 00:12:33
|
On 27 Jun 2001, at 1:58, Johan Lindstrom wrote: > This is where you call DoEvents() to give the GUI a chance to handle > messages and respond to user interaction every once in a while. Do > this "as often as possible" to give the impression that the GUI is > always listening to user interaction. So are you suggesting soemthing like this? sub SomeButton_Click { # first part of long piece of code Win32::GUI::DoEvents; # second part of long piece of code Win32::GUI::DoEvents; # third part of long piece of code Win32::GUI::DoEvents; # fourth part of long piece of code } > BTW, most of this has been said before a few times. Browse the > archives for more info. I would, but they haven't been working for a long time (for example, a search on 'Win32::GUI' returns nothing (even tried searching on each part separately, and without capitalization, etc.), even though I'm fairly confident that that term is somewhere in one of the posts. |
From: Johan L. <jo...@ba...> - 2001-06-27 06:30:18
|
Sean wrote: > > This is where you call DoEvents() to give the GUI a chance to handle > > messages and respond to user interaction every once in a while. Do > > this "as often as possible" to give the impression that the GUI is > > always listening to user interaction. > >So are you suggesting soemthing like this? -snip- Yes, although the most typical case contains a loop in which you put the DoEvents() call. Depends on your app of course :) > > BTW, most of this has been said before a few times. Browse the > > archives for more info. > >I would, but they haven't been working for a long time I chose the word "browse" with some deliberation, thankyouverymuch :) Actually, looking through the archives is a good introduction, not only to this list, but to what problems have been solved before (no need to try this or that again, it didn't work the last time). It will take you some time, but it's worth it. /J ------ ---- --- -- -- -- - - - - - Johan Lindström Boss Casinos Sourcerer jo...@ba... http://www.bahnhof.se/~johanl/ If the only tool you have is a hammer, everything tends to look like a nail |