David,

I can't see why you need to go in to the event processing loop at all for this.
Can't you just run your loop and then use a MessageBox window when an
error occurs?

If you wanted to give a status window you could create a window  whose only
component was a label that you could modify in your loop and then call the 
update
method.

I've used something like 

my $Win = new Win32::GUI::Window(
      -left   => 341,
      -top    => 218,
      -width  => 300,
      -height => 86,
      -name   => "Win",
      -text   => "Status Window"
      );

$Win->AddLabel(
       -text    => "  ",
       -name    => "Label",
       -left    => 5,
       -top     => 5,
       -width   => 280,
       -height  => 48,
      );

sub display {           #   Update status text
   my $text=shift;
   $Win->Show();
   $Win->BringWindowToTop();
   $Win->Refresh();
   $Win->Label->Text($text);
   $Win->Label->Update();
}

and called display("Text to display") in some of my programs for this.  
Alternatively
you could put in a ProgressBar and modify its status in a similar fashion.  
This avoids
going into the event loop completely. 

As far as I can see, if you do go into the event loop you'll need two 
processes, one in
the event loop and one running through your loop.  When the one running your 
loop
gets an error it will then need to communicate this to the process in the event 
loop
somehow.  I did experiment with using this approach and a timer but it seemed 
much
messier than just avoiding the event loop altogether.

Kev.





[EMAIL PROTECTED] on 03/01/2001 18:31:44
To: [EMAIL PROTECTED] @ INTERNET
cc:  

Subject: Re: [perl-win32-gui] Event processing

> okay, i think i see what you mean...you want a GUI that starts a loop
> which can conditionally spawn a second window, and when that second
> windows is closed, it returns to the loop and continues processing...

  yes.
 
> i can't figure it out either...my current theory is that since the
> Loop_Click event has not exited, another click event (OK_Click) cannot
> be registered...

  I would think this is a common problem.  If somebody want to process
  a file line by line looking for errors they would want to pop up a
  window to display the error and then let the user continue on with
  the processing.

> you can do something like this to exit the loop (thereby exiting the
> click event) prior to displaying the window, but then you have to pull
> some shysty manoeuvres to maintain state and get the loop going again:

  Yeah, that becomes a pain to deal with each time.

  I would think some kind of 'stop and wait' function would exist.  You
  can popup a message window, ie.

     Win32::GUI::MessageBox(0,"Some message","Info",64);

  ..and that will wait for a button click in the middle of a loop so I would
  think you could do this with a user-created window.

  -david


Reply via email to