开发者

Modal window from within message handler in WTL/Winapi

开发者 https://www.devze.com 2023-02-14 20:45 出处:网络
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

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 OnMess开发者_C百科ageWndHandler1(...)
{
     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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号