why no window popup
CFreeSenderDlg dlg;
m_pMainWnd = &dlg
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
::MessageBox(0,"ok",0,0);
}
else if (nResponse == IDCANCEL)
{
::MessageBox(0,"ok",0,0); // not pop up;
CDialog c(IDD_ABOUTBOX);
c.DoModal(); // not pop up;
}
else
{
::MessageBox(0,"操你妈,在那",0,0);
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
- Check the return value of all function calls for possible errors.
- Use debugger breakpoints to determine if the code you mention is really executed.
- If necessary, step through the code with the debugger.
derek7, have you confirmed that nResponse is ever equal to IDCANCEL, because if the other messagebox calls are working and the top DoModal is working, it would be very strange indeed if the ones you have flagged are not.
FreeSenderDlg definatly has a Cancel button?
[EDIT] Actually, come to think of it, MessageBox will return IDCANCEL if you close it with the little top-right cross button as well so if that isn't producing the desired behaviour in your program, no idea.
FreeSenderDlg definatly has a Cancel button?
[EDIT] Actually, come to think of it, MessageBox will return IDCANCEL if you close it with the little top-right cross button as well so if that isn't producing the desired behaviour in your program, no idea.
I answered in your other thread about this topic:
Simply comment the line
m_pMainWnd = &dlg
to
//m_pMainWnd = &dlg
Simply comment the line
m_pMainWnd = &dlg
to
//m_pMainWnd = &dlg
class CdialogMsgTestDlg : public CDialog{// 构造public: CdialogMsgTestDlg(CWnd* pParent = NULL); // 标准构造函数// 对话框数据 enum { IDD = IDD_DIALOGMSGTEST_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持// 实现protected: virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg void OnKillFocus(CWnd * w); afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP()public: afx_msg void OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult);};//CppBEGIN_MESSAGE_MAP(CdialogMsgTestDlg, CDialog) ON_WM_PAINT() ON_WM_KILLFOCUS() ON_WM_KEYDOWN() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnTvnSelchangedTree1)END_MESSAGE_MAP()void CdialogMsgTestDlg::OnKillFocus(CWnd * w){ CWnd *t = w->GetParent(); if (this == t) ::SetFocus(this->GetSafeHwnd()) ;}// CdialogMsgTestDlg 消息处理程序void CdialogMsgTestDlg::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ){ if(nChar == 'c') dash = !dash;}
OH mygod many problem arise.
1
OnChar OnKeyDown are not be call.
2
void CdialogMsgTestDlg::OnKillFocus(CWnd * w)
{
CWnd *t = w->GetParent();
if (this == t)
::SetFocus(this->GetSafeHwnd()) ;
} subcontrol still get focus.
3 MoveWindow(0,0,300,333); 0 is not valid ,if you
MoveWindow(1,1,300,333); this work. why?
1)
WM_KEYDOWN will not work for the dialog. You have to use PreTranslateMessage and check for WM_KEYDOWN there.
WM_CHAR ought to work when you process the WM_GETDLGCODE message and return DLGC_WANTALLKEYS.
2)
Is the focus setting only important when the dialog opens up? In that case return FALSE in OnInitDialog to prevent setting the default focus.
You should not call SetFocus inside a OnKillFocus handler.
3)
This should work as well. In what relation is the window you want to move?
WM_KEYDOWN will not work for the dialog. You have to use PreTranslateMessage and check for WM_KEYDOWN there.
WM_CHAR ought to work when you process the WM_GETDLGCODE message and return DLGC_WANTALLKEYS.
2)
Is the focus setting only important when the dialog opens up? In that case return FALSE in OnInitDialog to prevent setting the default focus.
You should not call SetFocus inside a OnKillFocus handler.
3)
This should work as well. In what relation is the window you want to move?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement