Modal window from within message handler in WTL/Winapi

490 views Asked by At

I have a small application that has a message only WTL window which does the background processing. But under some circumstances I would like to show a window that should behave as modal, that is, the message handler of message only window should not return until the user has clicked the button.

I was thinking that I could do it like this (pseudocode):

LRESULT OnMessageWndHandler1(...)
{
     CModalWindow wnd;
     wnd.create(...)

     while(GetMessageLoop){}
}

But when I try, the window is created just fine, but pressing a key outputs tens of characters in modal windows editbox, not a single one like in regular window.

Most likely I'm doing something wrong, but I don't know what and what should be the correct approach. The modal window is completely code generated.

2

There are 2 answers

0
Alain Rist On BEST ANSWER

I would like to show a window that should behave as modal ...

In my Unusual but Useful Dialog-based Classes Designed for Specialization you will find the way to call DoModal() on any control or homemade window.

0
Coder On

It was probably a bad idea in the first place. The code is just the regular message loop. I decided to resort to less exotic solution.