Dialog Hidden on Initialization
-
Why doesn't this work? I made a dialog based application in MFC. When the program is launched, I want it to be hidden. I'm using a global keyboard hook to respond to a key press and restore the window. This part works fine. It seems that i can hide the dialog by putting ShowWindow(SW_HIDE); in a button handler. So.. it works if i press a button on the dialog but not when the program starts. This code from Microsoft MSDN does not do anything. But it should: /* MyDialog.cpp */ #include "MyDialog.h" BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_cMyEdit.SetWindowText("My Name"); // Initialize control values m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } I've read in so many places that by putting ShowWindow(SW_HIDE); in the OnInitDialog(), it will hide the dialog when the program starts. It doesn't do anything for my program. But ShowWindow(SW_MINIMIZE) works in that location for some reason!!!!!!!! Even by setting the dialogs extended properties in the resource manager (unselecting the Visible checkbox), doesn't do anything. If i put the ShowWindow(SW_HIDE); in the application's initialization (before the command to CMyDialog.DoModal()), I get an exception message "Debug Assertion Failure"!! Why?!!??!!?!?!??
-
Why doesn't this work? I made a dialog based application in MFC. When the program is launched, I want it to be hidden. I'm using a global keyboard hook to respond to a key press and restore the window. This part works fine. It seems that i can hide the dialog by putting ShowWindow(SW_HIDE); in a button handler. So.. it works if i press a button on the dialog but not when the program starts. This code from Microsoft MSDN does not do anything. But it should: /* MyDialog.cpp */ #include "MyDialog.h" BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_cMyEdit.SetWindowText("My Name"); // Initialize control values m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } I've read in so many places that by putting ShowWindow(SW_HIDE); in the OnInitDialog(), it will hide the dialog when the program starts. It doesn't do anything for my program. But ShowWindow(SW_MINIMIZE) works in that location for some reason!!!!!!!! Even by setting the dialogs extended properties in the resource manager (unselecting the Visible checkbox), doesn't do anything. If i put the ShowWindow(SW_HIDE); in the application's initialization (before the command to CMyDialog.DoModal()), I get an exception message "Debug Assertion Failure"!! Why?!!??!!?!?!??
see here http://www.voidnish.com/articles/ShowArticle.aspx?code=dlgboxtricks[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta