开发者

Multi-window program

开发者 https://www.devze.com 2023-01-05 08:29 出处:网络
I read many articles on the topic, a few of them were here, on stackoverflow, but none of them asked my question. I\'ll try to be specific.

I read many articles on the topic, a few of them were here, on stackoverflow, but none of them asked my question. I'll try to be specific.

I need to create an application (native WinAPI) with a main window (of window class "a"). When the user clicks a button there, a window of "b" class pops up. It m开发者_运维技巧ight be modal or not, I don't care right now.

I tried making an application with two window classes and two window procedures. But the problem is that when I close the second window, the whole application shuts down.

Thank you.


At a guess, the window procedure for your second window is based on one for a main window, so when it receives a WM_DESTROY, it's calling PostQuitMessage. This is normal for the top-level window, because the user expects destroying it to mean exiting the application. For a child window (modal or otherwise) that's not the case though, so the child should not (again, normally) call PostQuitMessage in its WM_DESTROY handler.

0

精彩评论

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