MFC Assert
hey I am getting an assert with GetCurSel() in the combobox control. I tracked it down in the inl file and this is what it said
_AFXWIN_INLINE int CComboBox::GetCurSel() const
{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0); }
any ideas? Thanks.
InFerN0
Not all who wander are lost...
Is your HWND valid?
Usually MFC controls will assert if they haven''t been created before you attempt to perform a function that requires a valid HWND.
-fel
Usually MFC controls will assert if they haven''t been created before you attempt to perform a function that requires a valid HWND.
-fel
Fel''s right.
You have probably called it from a dialog that is no longer modal or the window has not been created yet.
Try placing it in OnInitDialog if before showing the window.
I''m guessing, you have placed the call after the window has been destroyed. Move it instead to an OnOk function.
You have probably called it from a dialog that is no longer modal or the window has not been created yet.
Try placing it in OnInitDialog if before showing the window.
I''m guessing, you have placed the call after the window has been destroyed. Move it instead to an OnOk function.
I have the call in a function outside the forms class. Before calling GetCurSel() I check my combo box pointer.
if(g_pParent->m_pCBObjectType == NULL)
{
MessageBox("Not in scope");
return;
}
I haven''t destroyed the window cause I can still see it and I know that it has been created because I test it on creation. Thanks.
InFerN0
Not all who wander are lost...
if(g_pParent->m_pCBObjectType == NULL)
{
MessageBox("Not in scope");
return;
}
I haven''t destroyed the window cause I can still see it and I know that it has been created because I test it on creation. Thanks.
InFerN0
Not all who wander are lost...
Your pointer to your class may be valid, but the hwnd of the combo box may not be. For instance, if the combo box is a member of a dialog that you have derived from CDialog, you can only operate on the combo box after calling "CDialog::InitDialog" from your OnInitDialog function. Before this function is called, all hwnds are invalid.
The dialog itself was made using the dialog editor in VC++ and is bound to a member of CMainFrame which handles all its messages. Actually the dialog is a dialogbar. Also I tried having the dialog get a safe HWND
m_RBar.GetSafeHwnd();
no effect. I know this fixs asserts in other places but not here.
InFerN0
Not all who wander are lost...
m_RBar.GetSafeHwnd();
no effect. I know this fixs asserts in other places but not here.
InFerN0
Not all who wander are lost...
Inferno....
what we mean, is that we wanna know if you call your GetCurSel() before or after you called
dlg.Create(this, CBRS_RIGHT, );
cause otherwise the HWND is not ok... it''s only valid _AFTER_ you called this function and _BEFORE_ the window is destroyed..
otherwise... does your prog crash in release mode? If not.. who cares? j/k...
hope that helps a bit.
cya,
Phil
P.s.: Just bought myself a huge Assembler book today.. Yummy
Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states
RAW!
what we mean, is that we wanna know if you call your GetCurSel() before or after you called
dlg.Create(this, CBRS_RIGHT, );
cause otherwise the HWND is not ok... it''s only valid _AFTER_ you called this function and _BEFORE_ the window is destroyed..
otherwise... does your prog crash in release mode? If not.. who cares? j/k...
hope that helps a bit.
cya,
Phil
P.s.: Just bought myself a huge Assembler book today.. Yummy
Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states
RAW!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement