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

1 Answer

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.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.