Document Class pointer error
Hi,
I am using embedde visual C++ and I have create a dialog box and a button call ID_BInsert.
Below is the code for button ID_BInsert:
-------------------------------------------------------------------------------------
void CNEWSERIALNO::OnBInsert()
{
// TODO: Add your control notification handler code here
CTokenEx tok;
CStringArray arr_SerialNo;
UpdateData (TRUE);
CString sSerialNo(m_sSerialNo);
tok.Split(sSerialNo, "\r\n", arr_SerialNo, FALSE);
CMobileInventoryDoc* pDoc = GetDocument();
for (int i =0; i < arr_SerialNo.GetSize(); i++)
{
AfxMessageBox(arr_SerialNo[i], MB_OK);
if (pDoc)
{
// Get the last record from the document
m_pCurItem = pDoc->GetLastRecord();
if (m_pCurItem)
{
m_pCurItem = pDoc->GetNextRecord();
if (m_pCurItem)
m_pCurItem->SetSerialNo(arr_SerialNo[i]);
}
}
}
}
-------------------------------------------------------------------------------------
When I compile and build the application, it give me the error as below:
C:\Documents and Settings\user1\My Documents\MobileInventory\NEWSERIALNO.cpp(61) : error C2065: 'GetDocument' : undeclared identifier
C:\Documents and Settings\user1\My Documents\MobileInventory\NEWSERIALNO.cpp(61) : error C2440: 'initializing' : cannot convert from 'int' to 'class CMobileInventoryDoc *'
The statement that cause the error is statement below:
CMobileInventoryDoc* pDoc = GetDocument();
But I have use this statement in view class and it is no problem.
May someone tell me what is the problem and how to solve it.
Thanks in advance.
Best Regards.
|