From: Yoel Lax on
I have a msgbox which updates during each iteration of a loop, like this:

for i = 1 : 1000
....
....
msg=msgbox('blablabla','Title','replace');
end


Now, I'd like the text in the msgbox to get updated without necessarily bringing the msgbox to the foreground. The reason is that sometimes the iterations go very quickly, and the constant "popping up" of the msgbox prevents me from doing anything else on my machine. But I do want to be able to make the msgbox visible by clicking on it on the taskbar.

It used to be the case that clicking on any window which covers the msgbox will keep the latter in the background, but somehow that hasn't been working for me lately.

Your help is greatly appreciated.


Running Matlab 7.5.0.342 on Windows XP Professional.
From: Walter Roberson on
Yoel Lax wrote:
> I have a msgbox which updates during each iteration of a loop, like this:
>
> for i = 1 : 1000
> ....
> ....
> msg=msgbox('blablabla','Title','replace');
> end
>
>
> Now, I'd like the text in the msgbox to get updated without necessarily
> bringing the msgbox to the foreground.

You cannot. msgbox() automatically figure()'s the box, thus bringing it
to the foreground. If I recall correctly it also automatically does a
drawnow() so you cannot even bury it immediately after it is created
without there being a flash.

If you examine the children of the figure handle that is returned, you
can find the child which holds the text; then on each iteration after
the first, you can set() that field's String to have the updated value
without changing the box's stacking order.
From: Yoel Lax on
Fantastic, this works!!

For anyone interested, the syntax is like this:

for i = 1 : 1000
....
....
if i ==1
msg=msgbox('blablabla','Title','replace');
CA = get(msg,'CurrentAxes');
Txt = get(CA,'Children');
else
set(Txt,'String','blablablablablabla')
drawnow update
end
end


The "drawnow update" is necessary to update the msgbox on the screen, without this line it will only update once the whole loop is finished.


Many thanks!!