Calling OnNewDocument from outside CMyApp ... 
Author Message
 Calling OnNewDocument from outside CMyApp ...

Hello all,

Initially I was trying to call a member function to get a
new CHtmlView document,

CHtmlView* CUIMApp::OnNewHtml() {

        ASSERT(m_pHtmlTemplate);
        CDocument* pDoc = m_pHtmlTemplate->OpenDocumentFile
(0);
        //pDoc->SetTitle("New Buddy");
        //POSITION pos = pDoc->GetFirstViewPosition();
        //return (CHtmlView*)pDoc->GetNextView( pos );
        return 0;

Quote:
}

but calling this like theApp.OnNewHtml(), causes an
unhandled excpetion (even though calling it from the menu
works everytime) ... failing on ASSERT(m_hWnd ==
hwnd) .. in winmdi.cpp, function CMDIChildWnd::Create
(...), line 585 , so Im trying to send it a
message so that CUIMApp can call it self.  CWinApp doesnt
have m_hWnd , so what is my first paramter to SendMessage ?

(I tried AfxGetMainWnd()->GetSafeHwnd() with no luck)

Thanks so much for any help!!  Please help!

Charles



Thu, 03 Nov 2005 07:54:57 GMT  
 Calling OnNewDocument from outside CMyApp ...
try set your initial data of your document and handle data in the
OnInitUpdate function of your view


Quote:
> Hello all,

> Initially I was trying to call a member function to get a
> new CHtmlView document,

> CHtmlView* CUIMApp::OnNewHtml() {

> ASSERT(m_pHtmlTemplate);
> CDocument* pDoc = m_pHtmlTemplate->OpenDocumentFile
> (0);
> //pDoc->SetTitle("New Buddy");
> //POSITION pos = pDoc->GetFirstViewPosition();
> //return (CHtmlView*)pDoc->GetNextView( pos );
> return 0;
> }

> but calling this like theApp.OnNewHtml(), causes an
> unhandled excpetion (even though calling it from the menu
> works everytime) ... failing on ASSERT(m_hWnd ==
> hwnd) .. in winmdi.cpp, function CMDIChildWnd::Create
> (...), line 585 , so Im trying to send it a
> message so that CUIMApp can call it self.  CWinApp doesnt
> have m_hWnd , so what is my first paramter to SendMessage ?

> (I tried AfxGetMainWnd()->GetSafeHwnd() with no luck)

> Thanks so much for any help!!  Please help!

> Charles



Thu, 03 Nov 2005 18:38:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CMyApp* app = (CMyApp*) (AfxGetApp()) - best way?

2. Multiple calls to OnNewDocument when In Place activated

3. Function calls from outside source file.

4. Calling outside programs w/ C

5. Calling outside functions from within a C script.

6. call stack information outside the debugger

7. Calling Dialog Function from outside their cpp

8. Calling SetRegistryKey outside of CWinApp instance

9. Closing a Prop Sheet with outside call

10. Call a main-dlg method from outside

11. calling CView methods outside of class

12. (Q) Which is better? ((CMyApp*) AfxGetApp()) or 'extern CMyApp theApp;'

 

 
Powered by phpBB® Forum Software