
How to create a Dialog based Application with MainDlg hidden on startup
Are you talking about a dialog based application? If so, how will you get
the Modal dialog back? That's really none of my business, so here's how I'd
do it in a Dialog base app:
Create a USER message and call it using PostMessage in the dialog's
OnInitDialog function. Then in the message handler, hide the window... You
have to "post" the message so that the dialog initializes before it is
hidden. If not, it will just be redisplayed when it finishes
initializing... The code will look as follows:
In the Header of the Dialog Class:
// Generated message map functions
//{{AFX_MSG(CMyTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
//}}AFX_MSG
afx_msg void OnHideWindow(); // ADD THIS LINE
DECLARE_MESSAGE_MAP()
In the CPP File:
BEGIN_MESSAGE_MAP(CMyTestDlg, CDialog)
//{{AFX_MSG_MAP(CMyTestDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_USER+1, OnHideWindow) // ADD THIS LINE
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
BOOL CMyTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
PostMessage(WM_USER+1); // ADD THIS LINE
return TRUE; // return TRUE unless you set the focus to a control
Quote:
}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// ADD THIS METHOD
void CMyTestDlg::OnHideWindow()
{
ShowWindow(SW_HIDE);
Quote:
}
Hope this helps and good luck,
Chris
Quote:
> No Content.
> Best regards!