newbie needs help
-
Probably another simple queston. I have used the same code in other dialog boxes, (with different variables)and it works. Thanks for the help. I get the following ASSERT at the line containing m_BeginStr.ResetContent(); _AFXWIN_INLINE void CComboBox::ResetContent() { ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0); } void CDlgOffset::OnButtonBrowse() { FILE *StrFile; CWnd* pWnd; CString sStrName; double E; double S; CFileDialog dlg( TRUE, "txt", NULL, OFN_FILEMUSTEXIST, "Text Files (*.txt)||\0" ,NULL ); int nResponse = dlg.DoModal(); if (nResponse == IDOK) { m_StrFile = dlg.GetPathName(); pWnd = GetDlgItem( IDC_EDIT2 ); pWnd->SetWindowText( m_StrFile ); // Load the Combo Boxes StrFile = fopen( m_StrFile, "r+"); fseek( StrFile, 0L, SEEK_SET ); m_BeginStr.ResetContent(); m_EndingStr.ResetContent(); while( fscanf( StrFile, "%s %lf %lf", sStrName, &E, &S ) != EOF ) { m_BeginStr.AddString( sStrName ); m_EndingStr.AddString( sStrName ); } fclose( StrFile ); } }
-
Probably another simple queston. I have used the same code in other dialog boxes, (with different variables)and it works. Thanks for the help. I get the following ASSERT at the line containing m_BeginStr.ResetContent(); _AFXWIN_INLINE void CComboBox::ResetContent() { ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0); } void CDlgOffset::OnButtonBrowse() { FILE *StrFile; CWnd* pWnd; CString sStrName; double E; double S; CFileDialog dlg( TRUE, "txt", NULL, OFN_FILEMUSTEXIST, "Text Files (*.txt)||\0" ,NULL ); int nResponse = dlg.DoModal(); if (nResponse == IDOK) { m_StrFile = dlg.GetPathName(); pWnd = GetDlgItem( IDC_EDIT2 ); pWnd->SetWindowText( m_StrFile ); // Load the Combo Boxes StrFile = fopen( m_StrFile, "r+"); fseek( StrFile, 0L, SEEK_SET ); m_BeginStr.ResetContent(); m_EndingStr.ResetContent(); while( fscanf( StrFile, "%s %lf %lf", sStrName, &E, &S ) != EOF ) { m_BeginStr.AddString( sStrName ); m_EndingStr.AddString( sStrName ); } fclose( StrFile ); } }
has m_BeginStr been initialized? chances are that it isn't yet a "window" (and the ::IsWindow test is failing). make sure you're either DDX'ing the control or SubClassing it (ie. attaching an actual control to the variable) -c
“losinger is a colorizing text edit control” -- googlism
-
look in the DoDataExchange function of your dialog. do you see a line that looks something like this: DDX_Control(pDX, IDC_MY_COMBOS_ID, m_BeginStr); ? if not, it needs one. otherwise, the member variable is never actually attached to the control. -c
“losinger is a colorizing text edit control” -- googlism
-
has m_BeginStr been initialized? chances are that it isn't yet a "window" (and the ::IsWindow test is failing). make sure you're either DDX'ing the control or SubClassing it (ie. attaching an actual control to the variable) -c
“losinger is a colorizing text edit control” -- googlism
-
It is there. void CDlgO::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgOffset) DDX_Control(pDX, IDC_COMBO_END_STR, m_EndingStr); DDX_Control(pDX, IDC_COMBO_BEG_STR, m_BeginStr);
hmmm. can you put a breakpoint on that DDX line and step into the DDX_Control code to see if anything fails? -c
“losinger is a colorizing text edit control” -- googlism
-
look in the DoDataExchange function of your dialog. do you see a line that looks something like this: DDX_Control(pDX, IDC_MY_COMBOS_ID, m_BeginStr); ? if not, it needs one. otherwise, the member variable is never actually attached to the control. -c
“losinger is a colorizing text edit control” -- googlism
-
hmmm. can you put a breakpoint on that DDX line and step into the DDX_Control code to see if anything fails? -c
“losinger is a colorizing text edit control” -- googlism