Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cause the close 'cross' button to hide my window instead of destroy it

Status
Not open for further replies.

XeNoR

Programmer
Jun 1, 2002
6
US
Is there a way that I can make it so that when someone clicks the close 'cross' button in the upper right corner of the window, it does not destroy the window, but, rather, hide the window? Like with ShowWindow(hWnd, SW_HIDE)

 

Over ride OnCancel and remove CDialog::OnCancel() like this:

void CMyDialogDlg::OnCancel()
{
ShowWindow(FALSE);
Sleep(5000);
ShowWindow(TRUE);

// CDialog::OnCancel();
}

The above code will hide the window for 5 seconds then show it again when you click on close. You don't need to use ShowWindow(hWnd, SW_HIDE), CDialog class has it's own ShowWindow function that comes from CWnd so you'll find most views including the frame have this too.

Brother C
 
I dont have any code like that.... im thinking that is MFC or something? i dunno... but assuming that is MFC, is there a way i can do it without MFC?
 
Override the window process and on WM_CLOSE, hide the window as opposed to PostQuitMessage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top