简体   繁体   中英

Prevent X Button Close MFC Dialog

I want to prevent my MFC dialog from being closed when window X button clicked, instead I want my windows to be hidden like ShowWindow(SW_HIDE);

I tried WM_ON_CLOSE, I get close message, I save my work, but can't prevent termination of my program and minimizing to tray.

I want to prevent X button from closing my dialog, instead hiding it.

Thanks in advance

Try adding a WM_SYSCOMMAND handler and trap the SC_CLOSE command.

But before you do that, please rethink whether you want to do this. The close button is one of the most fundamental controls in Windows, and overriding its behavior can only be confusing.

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