ShowWindow不行,看看InitInstance()中的源代码: CMyDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); //<--------------------|| if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel }
bool m_bFirst; OnPaint()如下:
void CMyPadDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
if (m_bFirst) //添加了这几行。本方法也可用于启动隐藏
{
m_bFirst = false;
ShowWindow(SW_SHOWMINIMIZED);
}
else
{
CDialog::OnPaint();
}
}
}
m_pMainWnd->ShowWindow(SW_SHOW);
改为:
m_pMainWnd->ShowWindow(SW_SHOW|SW_MINIMIZE);
的方法不我在2000下不行!!!
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal(); //<--------------------||
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
if (m_bFirst) //添加了这几行。本方法也可用于启动隐藏
{
m_bFirst = false;
ShowWindow(SW_SHOWMINIMIZED);
}
}
void CYDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
ShowWindow(SW_MINIMIZE);
CDialog::OnShowWindow(bShow, nStatus);
}