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_SYSCOMMANDhandler and trap theSC_CLOSEcommand.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.