Hide a CDialogImpl dialog when user cancels

Go To StackoverFlow.com

0

Using a CDialogImpl derived class as a dialog-based WTL/ATL app, I want to hide the main window when the user clicks the upper right "X" button (or presses Esc or Alt+F4).

Currently the "X" closes the dialog and ends the application.

enter image description here

I want to change this behaviour and only hide the dialog box instead of closing it. Is this possible?

2012-04-04 06:23
by Uwe Keim


2

I'm not sure if ATL/WTL provides some wrapper for this but in WinAPI, the function you are looking for is ShowWindow, which you would invoke as so:

ShowWindow(hwnd, SW_HIDE);

If you want this to happen when the application is closed, the message you need to handle is WM_CLOSE.

After a quick search, MSDN reveals CWindow::ShowWindow, which is the wrapper I mentioned earlier.

2012-04-04 12:37
by Mike Kwan
Ads