
Minimizing a dialog-based application on startup...?
Quote:
>When clicking
>on the Hide button I just call ShowWindow(SW_HIDE). However I also want this
>application to hide itself when started up. So I guessed I put the same call
>into the OnInitDialog function, however that does not work.
Rob,
I've not come across a really elegant way of doing this. The best I've
got is to post a user defined message in OnInitDialog, and position
the dialog off-screen. In the processing of the user defined message
hide the window, and when you want to display it you can reposition
it. Here's the general idea:
BEGIN_MESSAGE_MAP(CMindlgDlg, CDialog)
//{{AFX_MSG_MAP(CMindlgDlg)
...
//}}AFX_MSG_MAP
ON_MESSAGE( WM_APP+1, OnAppMsg )
END_MESSAGE_MAP()
BOOL CMindlgDlg::OnInitDialog()
{
...
// TODO: Add extra initialization here
SetWindowPos( NULL, -1000, -1000, 0, 0,
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
PostMessage( WM_APP+1 );
return TRUE;
Quote:
}
LRESULT CMindlgDlg::OnAppMsg(WPARAM, LPARAM)
{
ShowWindow( SW_HIDE );
return 0;
Quote:
}
Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.