简体   繁体   中英

In win32 programming, If I create another top level window, do I need a separate window procedure for it?

I've run into an issue in my application that creates several top level windows (besides the main window):

The issue is that if I close any of the top level windows, my main window also closes. It took me several days to understand what was happening and I think I got it. It looks like the other top level windows use the same window procedure that my main window uses, as a result when I close any of the top level windows, the window procedure receives the WM_CLOSE message and that shuts down the whole application.

Therefore I've a question - if I create a new top level window, do I need to register a new class and associate a new window procedure for it?

Your window proc is presumably responding to WM_DESTROY by calling PostQuitMessage. Which brings the process down. You should only call PostQuitMessage when the main window closes. You can do this from a shared window procedure so long as you discriminate using the window handle that is handling the WM_DESTROY message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM