//类成员:
CModelessDlg *m_pModelssDlg;//初始
m_pModelssDlg=new CModelessDlg;//创建地方
m_pModelssDlg->Create(IDD_DLG_MODELESS);
m_pModelssDlg->ShowWindow(SW_SHOW);
BOOL CModelessDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // TODO: Add extra initialization here
SetTimer(1,2000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//timer 不能响应?
void CModelessDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
OnCancel();
CDialog::OnTimer(nIDEvent);
} //没有任何消息
BOOL CModelessDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreTranslateMessage(pMsg);
}为什么不能响应内 ?
CModelessDlg *m_pModelssDlg;//初始
m_pModelssDlg=new CModelessDlg;//创建地方
m_pModelssDlg->Create(IDD_DLG_MODELESS);
m_pModelssDlg->ShowWindow(SW_SHOW);
BOOL CModelessDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // TODO: Add extra initialization here
SetTimer(1,2000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//timer 不能响应?
void CModelessDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
OnCancel();
CDialog::OnTimer(nIDEvent);
} //没有任何消息
BOOL CModelessDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreTranslateMessage(pMsg);
}为什么不能响应内 ?
那就改成
TRACE0("\r\n[CModelessDlg] OnTimer");
好了!
我问的是为什么非模态对话框不能响应消息,不是 》。
BOOL CModelessDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // TODO: Add extra initialization here
SetTimer(1,2000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
中的SetTimer(1,2000,NULL);
在主窗口中的void CMainDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
} 得到响应,而没有传递到CModelessDlg中去
用向导加的你说呢?
BEGIN_MESSAGE_MAP(CModelessDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &CModelessDlg::OnBnClickedButton1)
ON_WM_TIMER()
END_MESSAGE_MAP()
如果有某个窗体已经响应过消息,则消息不再进行传递。所有上面主窗体响应了,非模态对话框就不响应了
如果是模态对话框,则会响应,因为模态对话框是当前对话框
BOOL CModelessDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreTranslateMessage(pMsg);
}
{
CDialog::OnInitDialog(); // TODO: Add extra initialization here
SetTimer(1,2000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
中的SetTimer(1,2000,NULL);
在主窗口中的void CMainDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
}
囧,你在
CModelessDlg类的OnInitDialog中调用SetTimer();怎么在CMainDlg中处理WM_TIMER消息呢?
[email protected]
导致你的modlees窗口的任何消息都处于挂起状态