Code: Select all
Debug assertion failed !
File Afxwin2.inl, line 265
Code: Select all
_AFXWIN_INLINE CWnd* CWnd::GetParent() const
{ ASSERT(::IsWindow(m_hWnd)); return CWnd::FromHandle(::GetParent(m_hWnd)); }
Code: Select all
Debug assertion failed !
File Afxwin2.inl, line 265
Code: Select all
_AFXWIN_INLINE CWnd* CWnd::GetParent() const
{ ASSERT(::IsWindow(m_hWnd)); return CWnd::FromHandle(::GetParent(m_hWnd)); }
Desigur...mesajflaviu wrote: v-ati mai intalnit cu aceasta eroare ?
Code: Select all
CMyDialog dlg;
dlg.DoModal();
dlg.GetParent(); // Shows "Debug Assertion Failed!" message box.
Hint: dupa ce apesi butonelul "Retry" ca sa vezi unde-i ASSERT-ul, da o fuga pe Call Stack si vezi de unde se-mpute treaba.mesajflaviu wrote: Nu am putut afla nici macar sursa ei ... orice hint ar fi binevenit !
Code: Select all
CWnd::GetParent() line 265 + 46 bytes
Code: Select all
CMyMessageBox MsgBox;
MsgBox.SetMessage(sDocMessage);
.............
UINT uRet = MsgBox.DoModal();
Code: Select all
UINT uRet = AfxMessageBox(sDocMessage, MB_ICONERROR | MB_ABORTRETRYIGNORE, 0);
Code: Select all
void CMyMessageBox::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CMyMessageBox::OnButtonNexti()
{
// TODO: Add your control notification handler code here
EndDialog(IDRETRY);
}
void CMyMessageBox::OnButtonNextv()
{
// TODO: Add your control notification handler code here
EndDialog(IDIGNORE);
}
Desigur.mesajflaviu wrote: Nu, nu mai folosesc obiectul dlg dupa apelul DoModal, iar call stack-ul ma duce la aceeasi linie:mai trebuie sa sap ...Code: Select all
CWnd::GetParent() line 265 + 46 bytes
Tu, direct, poate ca nu, insa poate chemi ceva care la randul lui cheama GetParent. Tot bietul call stack iti poate arata.mesajflaviu wrote:Culmea e ca nu folosesc nicaieri GetParent().
OK, insa nu ne-ai aratat ce face acel SetMessage. Banui vrea sa seteze textul la vreun copilas si-atuncea crapa.mesajflaviu wrote:Cred ca am dat de o urma:
in program, folosesc un dialog modal, CMyMessageBox : public CDialog, pe post de message box :[...]Code: Select all
CMyMessageBox MsgBox; MsgBox.SetMessage(sDocMessage); ............. UINT uRet = MsgBox.DoModal();
Code: Select all
CFBMessageBox MsgBox;
UINT uRet = MsgBox.DoModal();
Code: Select all
// UINT uRet = MsgBox.DoModal();
UINT uRet = MessageBox(sDocMessage, NULL, MB_ICONERROR | MB_ABORTRETRYIGNORE);
Pai nu-i nimic ciudat pentru ca-s doua lucruri diferite.mesajflaviu wrote:Ce mi se pare ciudat, e ca merge cu:Code: Select all
// UINT uRet = MsgBox.DoModal(); UINT uRet = MessageBox(sDocMessage, NULL, MB_ICONERROR | MB_ABORTRETRYIGNORE);
Code: Select all
CWnd::GetParent() line 265 + 46 bytes
CWnd::FilterToolTipMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 489 + 11 bytes
CWnd::_FilterToolTipMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}, CWnd * 0x001e41e8 {CFBDlgBar hWnd=???}) line 348
CWnd::PreTranslateMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 1027
CControlBar::PreTranslateMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 351 + 12 bytes
CFBDlgBar::PreTranslateMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 187
CWnd::WalkPreTranslateTree(HWND__ * 0x00030408, tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 2667 + 18 bytes
CWinThread::PreTranslateMessage(tagMSG * 0x00457f10 {msg=0x00000100 wp=0x0000001b lp=0x00010001}) line 672 + 18 bytes
CWinThread::PumpMessage() line 848 + 30 bytes
CWinThread::Run() line 487 + 11 bytes
CWinApp::Run() line 400
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x002426d8, int 1) line 49 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x002426d8, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 77101174()
NTDLL! 77b5b3f5()
NTDLL! 77b5b3c8()
Code: Select all
class CFBMessageBox : public CDialog
{
// Construction
public:
CMyMessageBox(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMyMessageBox)
enum { IDD = IDD_FBMESSAGEBOX_DIALOG };
CStatic m_StaticError;
//}}AFX_DATA
void EnableButtonNextItem(BOOL bEnable){m_bEnableNext = bEnable;}
void EnableButtonNextValid(BOOL bEnable){m_bEnableValid = bEnable;}
void SetMessage(CString sMessage){m_sMessage = sMessage;}
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyMessageBox)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
protected:
CString m_sMessage;
BOOL m_bEnableNext, m_bEnableValid;
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMyMessageBox)
virtual BOOL OnInitDialog();
virtual void OnCancel();
afx_msg void OnButtonNexti();
afx_msg void OnButtonNextv();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Code: Select all
CFBMessageBox::CFBMessageBox(CWnd* pParent /*=NULL*/)
: CDialog(CFBMessageBox::IDD, pParent)
{
//{{AFX_DATA_INIT(CFBMessageBox)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bEnableNext = m_bEnableValid = TRUE;
}
void CFBMessageBox::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFBMessageBox)
DDX_Control(pDX, IDC_STATIC_ERROR, m_StaticError);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFBMessageBox, CDialog)
//{{AFX_MSG_MAP(CFBMessageBox)
ON_BN_CLICKED(IDC_BUTTON_NEXTI, OnButtonNexti)
ON_BN_CLICKED(IDC_BUTTON_NEXTV, OnButtonNextv)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFBMessageBox message handlers
BOOL CFBMessageBox::OnInitDialog()
{
CDialog::OnInitDialog();
GetDlgItem(IDC_BUTTON_NEXTI)->EnableWindow(m_bEnableNext);
GetDlgItem(IDC_BUTTON_NEXTV)->EnableWindow(m_bEnableValid);
GetDlgItem(IDC_STATIC_MESSAGE)->SetWindowText(m_sMessage);
if(NULL == m_StaticError.GetIcon())
m_StaticError.SetIcon(::LoadIcon(NULL, IDI_ERROR));
if(m_bEnableNext)
{
HWND hWndCtrl = ::GetDlgItem(m_hWnd, IDC_BUTTON_NEXTI);
PostMessage(WM_NEXTDLGCTL, (WPARAM)hWndCtrl, (LPARAM)TRUE);
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFBMessageBox::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CFBMessageBox::OnButtonNexti()
{
// TODO: Add your control notification handler code here
EndDialog(IDRETRY);
}
void CFBMessageBox::OnButtonNextv()
{
// TODO: Add your control notification handler code here
EndDialog(IDIGNORE);
}
Code: Select all
BOOL CFBDlgBar::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
m_ToolTip.RelayEvent(pMsg);
return CDialogBar::PreTranslateMessage(pMsg);
}