dialog-box.
a patch, but I solved the problem at the root, now it is working fine).
Why not make the progress dialog non-modal. Then you could start the
progress dialog and the thread from the original button code. The thread
could send a message to the progress dialog to close when it's done.
Or, you could just have progress bar on the main dialog that you hide
until needed and not have a pop up window at all. You could even put the
progress bar on the status bar (if there is one).
Or, you could start the thread from the progress dialog's OnInitDialog()
(remember at that point the dialog can start getting window update
messages) and just have the thread send a message to the progress dialog
indicating that it completed.
I guess there are tons of ways to accomplish this kind of thing.
Have you seen this code:
http://www.codeproject.com/KB/winsdk/UPDialog.aspx
http://www.codeproject.com/KB/miscctrl/progresswnd.aspx
Since you would likely assign the window to the thread object (for it to
us to post messages) I think either of these would work for you.
Tom
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message
news:uEi1JUHzIHA.4912@TK2MSFTNGP03.phx.gbl...
Hi all,
I have a dialog-box: when the user presses a button, I would like to show
a new modal dialog-box with a progress bar indicating some potentially
lengthy operation progress. This operation is done by a worker thread.
(The worker thread sends messages to the GUI thread, to update progress
bar position.)
The problem is that I can't start the thread or send messages to the
progress bar from OnInitDialog. So, I thought about this "work-around":
in OnInitDialog, I create a timer (just 200 ms), and return.
When the timer "ticks" for the first time (i.e. after 200 ms since
OnInitDialog returned), the OnTimer handler calls another member function
of the dialog-box. This member function starts the worker thread, which
can now send messages to GUI thread to update the progress bar (in fact,
after OnInitDialog, the progress bar is ready to process messages).
(KillTimer is immediately called to avoid new firing of timer events.)
Everything is working fine.
I just would like to know if there is any different solution to that
problem, instead of using a one-shot timer to postpone beginning of work
after OnInitDialog.
Thanks,
Giovanni