|
-
October 21st, 1999, 03:44 AM
#1
assert problem
Why does the program stop here?
void CWnd::GetWindowText(Cstring& rString) const
{
XXX ASSERT(::IsWindow(m_hWnd));
}
void Hyrut::OnOK()
{
// TODO: Add extra validation here
//UpdateData (TRUE);
CTestSet Set;
int hittad = 0;
CString strText;
XXX m_editBox.GetWindowText(strText);
Set.m_strFilter = CString("KundId = ") + m_strKundId;
Set.Open(CTestSet::snapshot, "Kund");
Set.MoveFirst();
while (!Set.IsEOF() && hittad == 0)
{
if(Set.m_Kund_KundId == strText)
{
Kunden Kund;
Kund.DoModal();
hittad = 1;
}
Set.MoveNext();
if (hittad == 0)
{
MessageBox ("Kunden fanns ej");
Registrera Regi;
Regi.DoModal();
}
CDialog::OnOK();
}
}
-
October 21st, 1999, 04:48 AM
#2
Re: assert problem
The ASSERT checked if m_editBox->m_hWnd is a window. It isn't, so the IsWindow() function returns FALSE, thereby triggering the Assertion failure. You can't set text in a non-valid window.
Check your code to see how you initialized m_editBox, and to make sure that you are calling GetWindowText() when the window is valid (you can check this yourself by inspecting the m_editBox->m_hWnd value and verifying that the value is reasonable).
Regards,
Paul McKenzie
-
October 21st, 1999, 05:09 AM
#3
Re: assert problem
thanks for answering!!
the m_editBox is a CEdit and we haven't initialized it in the constructor. Should we and with what value?
we're using it like this:
m_editBox.GetWindowText(m_strKundId);
m_strKundId is connected to the editbox in our dialog.
-
October 21st, 1999, 05:27 AM
#4
Re: assert problem
> "m_strKundId is connected to the editbox in our dialog."
If this is true (a CString member variable), then after UpdateData(TRUE) m_strKundId ALREADY contains the text in the edit box - you do not need to call GetWindowText().
Where is m_editBox declared and first attached? The only way you can use a variable like this is (1) if you have declared it yourself and called SubclassDlgItem() during OnInitDialog() to attach it to an existing edit box, or (2) if you have used Class Wizard to add a member variable of type CEdit to an edit box at design time.
If m_strKundId is a CString member variable mapped to the edit box, forget m_editBox - it is not needed.
-
October 21st, 1999, 05:35 AM
#5
Re: assert problem
Hi Andre,
m_editBox shouldn't be initialized in the constructor. It needs a valid window handle, and the dialog window (and with it the edit control) is created when the dialog class is in the OnInitDialog function. Initialize it in the DoDataExchange, which is called by the base implementation of OnInitDialog.
Martin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|