|
From: <or...@vp...> - 2003-10-02 18:09:02
|
Geoff Baker wrote:
> I am trying to setup a Push Button control that when pushed, runs a series
> of commands, then calls itself to be run again. The reason behind this is
> that there is another thread that needs to process some data prior to the
> second half of the function being run. To do this I thought I could simply
> send a message to my main window (put the message into the que) so that once
> the other threads message has completed the button will be recalled.
> However this does not seem to happen, it simply ignores my sendmesage (or so
> it seems)
>
> Code:
> case 508:
> switch(setup)
> {
> case 0:
> FindSearch=FindInBuffer("]#",2);
> if(FindSearch==1)
> {
> MessageBox(NULL,"Prompt
> Check","Error",MB_OK|MB_ICONEXCLAMATION);
> }
> setup=1;
> break;
> case 1:
> FindInBuffer("]#",1);
> Command(" ",hwnd);
>
> SendMessage(hwnd,WM_COMMAND,(WPARAM)NULL,(LPARAM)508);
> break;
> }
> break;
> End Code:
>
> Does anyone know how to handle a situation like this?
Note, that SendMessage() directly calls the Window procedure again, so
you'll get a re-entrant (that is, you re-enter the procedure). This
should cause no trouble at all, as it happens a lot of time. For
example, when you create a dialog box, that is always on top of your
program. That means, the dialogbox call will return ONLY if you close
the dialog box, but if you move around the box, your Window proc will be
called evetually again with WM_PAINT (though it should be locked because
of the dialog box).
You should be careful with calling the same Window proc from within, as
SendMessage will only return, if the window proc - for which it sends
the message - finishes it's work. This way, you can easily get an
endless loop. I don't know if Windows checks for this, but according to
what Carlos wrote, it seems it does.
--
Greetings,
Balázs
|