Click to See Complete Forum and Search --> : Creating a CRecordView dynamically?
John Kelley
April 13th, 1999, 06:30 PM
When I create an application based on CEditView, I can't seem add a CRecordView as an option. From Mainfrm.cpp, I try to add a menu option to create a new CRecordView, but if I try to even declare an object of this type, I get an error indicating that the Constructor (the Destructor is, too) is protected. So, I found out that CRecordView is a runtime class, but how do I create it?
void CMainFrame::OnMyRecordView()
{
}
What do I put in this function if I can't create an object of type CRecordView?
Thanks for any help!
"Try not. Do, or do not. There is no try." - Yoda
chris law
April 14th, 1999, 02:30 AM
Do you want to create an additional view?
in InitInstance register another doc template with the RecordView view class
then call CreateNewFrame with doc pointer set to current document.
Otherwise you would have to dynamically create the object through the runtime class...
hope this offers some help...
(just do it)
chrislaw
John Kelley
April 14th, 1999, 10:24 AM
In that case, I guess my question is how do I dynamically create the object through the runtime class? In the online help, I found the following:
void CMainFrame::OnViewInventory()
{
CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CMyRecordView );
CObject* pObject = pRuntimeClass->CreateObject();
ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CMyRecordView ) ) );
}
But using just this code does not bring up the view. However, I still cannot use CMyRecordView to declare an oject, and CObject doesn't seem to do anything, either.
Any suggestions?
Thanks again!
"Try not. Do, or do not. There is no try." - Yoda
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.