Saving OCAF Documents

Me Again!
Now that I have got the app to run, I can't get it to save an OCAF document.
Can anybody see where I am going wrong?
I am implementing under OnSaveDocument. Code is listed below.

BOOL CLeonardoDoc::OnSaveDocument(LPCTSTR lpszPathName)
// TODO: Add your specialized code here and/or call the base class

int res = CDocument::OnSaveDocument(lpszPathName);

// Saving OCAF Document

// Get OCAF Application
Handle(TLeo_Application) LeoApp= ((CLeonardoApp*)AfxGetApp())->GetApp();
CString extension = "leo";
CString CSPath(lpszPathName);

// If extension not defined add defalult extension
if(CSPath.Find('.') == -1 ) {
// Remove file without extension
CSPath += "." + extension;

Standard_CString SPath = (Standard_CString)(LPCTSTR) CSPath;
TCollection_ExtendedString TPath(SPath);

// Saves the document in the current application

return res;

My OnNewDocument code:-

BOOL CLeonardoDoc::OnNewDocument()
if (!CDocument::OnNewDocument())
return FALSE;

// TODO: add reinitialization code here
// (SDI documents will reuse this document)

Handle(TLeo_Application) LeoApp = ((CLeonardoApp*)AfxGetApp())->GetApp();

// Create a new Ocaf document

Handle(AIS_InteractiveContext) CTX;
TPrsStd_AISViewer::Find(myOcafDoc->Main(), CTX);

return TRUE;

Many Thanks

Steve Howgill

shelleycao's picture

Hi, I encounter the same problem! How can I fix this trouble!

med's picture

I have the same problem OCC 6.1