• Advertisement
Sign in to follow this  

why no window popup

This topic is 4255 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;

Share this post


Link to post
Share on other sites
Advertisement

  1. Check the return value of all function calls for possible errors.
  2. Use debugger breakpoints to determine if the code you mention is really executed.
  3. If necessary, step through the code with the debugger.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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);
};



//Cpp

BEGIN_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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement