C (175/207)

From:Bob Lanham
Date:27 Dec 99 at 04:31:19
Subject:Re: event handling problem

From: Bob Lanham <bobl@jaxproductions.com>

>
> After this break, you restart the cycle, getting a message from the window you just closed (this is not advisable ;-)
> Perhaps inserting a:
>
> while (message=(struct IntuiMessage *)GetMsg(win->UserPort)) ReplyMsg((struct Message *)message);
>
> Before CloseWindow() (to answer all messages), then return (instead of break;)
>

Steffen,

Thanks for the tip regarding break/return. It gave me the idea of
replying to any and all messages at the top, before going into the
switch block, and only dealing with a single possible message. It
works!

message = (struct IntuiMessage *)GetMsg(win->UserPort);
mclass = message->Class;
code = message->Code;

// reply to all messages
while (NULL != (message = (struct IntuiMessage
*)GetMsg(win->UserPort)))
ReplyMsg((struct Message *)message);

switch (mclass)
{
case IDCMP_CLOSEWINDOW:
ClearMenuStrip(window2);
CloseWindow(window2);
window2=NULL;
win2open=FALSE;
break;
case etc...
case etc...
}
return(done);