Link to home
Start Free TrialLog in
Avatar of Smave
Smave

asked on

Contents of an EditBox

I have an MFC project where the main form is based on CDAORecordView.

The EditBox's ID is: IDC_EDIT_CurrentRecord
its value member variable is long m_CurrentRecord.
its control member variable is CEdit m_CurrentRecordCTRL.

As I use the record selectors in the toolbar I have use the GetAbsolutePosition function to update the m_CurrentRecord member variable.

During runtime, when I change the value of the EditBox I want the form to Move to the record number in the EditBox.

The following code compiles with no errors.

void CTheoFrontEndView::OnKillfocusEDITCurrentRecord()
{
     // TODO: Add your control notification handler code here
     CString strTemp;
     m_CurrentRecordCTRL.GetDlgItemText(IDC_EDIT_CurrentRecord, strTemp);

     m_pSet->SetAbsolutePosition(atol(strTemp));
}

The problem is the GetDlgItemText returns NULL.
Why?

also

How can I get the contents of the EditBox independant of its member variable?
or
Am I approching this problem all wrong?

Dave
Avatar of gandalf79
gandalf79

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
 int nRetCode = 0;
 
 // initialize MFC and print and error on failure
 if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
 {
  // TODO: change error code to suit your needs
  cerr << _T("Fatal Error: MFC initialization failed") << endl;
  nRetCode = 1;
 }
 else
 {
  // TODO: code your application's behavior here.
  CString strHello;
  strHello.LoadString(IDS_HELLO);
  cout << (LPCTSTR)strHello << endl;
 
  //here is where I want to 'cout' the contents of the fields in
  //the table
  BTable* pBTbl1 = new BTable(NULL);
  if(!pBTbl1->IsOpen())
   pBTbl1->Open();
 
  cout << "PrimeKey: " << pBTbl1->m_PrimeKey << endl;
  cout << "Book Title: " << (LPCTSTR)pBTbl1->m_BookTitle << endl;
  cout << "Book Number: " << pBTbl1->m_BookNumber << endl;
  cout << "Chapter: " << pBTbl1->m_Chapter << endl;
  cout << "Verse: " << pBTbl1->m_Verse << endl;
  cout << "English: " << (LPCTSTR)pBTbl1->m_1769_Authorized << endl;
  cout << "Non-English: " << (LPCTSTR)pBTbl1->m_NotEnglish << endl;
 
  pBTbl1->Close();
  delete pBTbl1;
 }
 
 return nRetCode;
}
ASKER CERTIFIED SOLUTION
Avatar of Yechezkel
Yechezkel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Smave

ASKER

It worked perfect.

Thank you!