Doc pointer in the MainFrame 
Author Message
 Doc pointer in the MainFrame

I am trying to get a pointer to the Document in my Mainframe but I can't
do that just by using GetActiveDocument.

for somereason this only works if the view is already existing, but in
my case the document is started then the Maingframe does some functions
and at some point I need to use a function in the Document again while I
am in the MainFrame, but I can't do that since my pointer is always
NULL.

I am running in an SDI environment and I pop-up some dialogs in the
process of going from the Document to the MainFrame but all the dialogs
are then destroyed before the next one is shown

Please let me know if it is possible to access the Document from the
MainFrame in a anyway possible.

thanx

  SamaanAN.vcf
< 1K Download


Sun, 19 May 2002 03:00:00 GMT  
 Doc pointer in the MainFrame
Albert,

How are you creating the document before the view? In a normal MFC app the
frame window, view, and document objects are all created by the call to
ProcessShellCommand in the application class InitInstance method.

The frame window method GetActiveDocument uses GetActiveView to find the
view first, then uses the views GetDocument method to find the document.
Therefore, this will not work if you have a document without a view.

Maybe you need to tuck away a pointer to the document at the time it is
created.

Dave Smith
MCSE, MCT, MVP


Quote:
> I am trying to get a pointer to the Document in my Mainframe but I can't
> do that just by using GetActiveDocument.

> for somereason this only works if the view is already existing, but in
> my case the document is started then the Maingframe does some functions
> and at some point I need to use a function in the Document again while I
> am in the MainFrame, but I can't do that since my pointer is always
> NULL.

> I am running in an SDI environment and I pop-up some dialogs in the
> process of going from the Document to the MainFrame but all the dialogs
> are then destroyed before the next one is shown

> Please let me know if it is possible to access the Document from the
> MainFrame in a anyway possible.

> thanx



Sun, 19 May 2002 03:00:00 GMT  
 Doc pointer in the MainFrame

Quote:
>I am trying to get a pointer to the Document in my Mainframe but I can't
>do that just by using GetActiveDocument.

>for somereason this only works if the view is already existing, but in
>my case the document is started then the Maingframe does some functions
>and at some point I need to use a function in the Document again while I
>am in the MainFrame, but I can't do that since my pointer is always
>NULL.

Albert,

From CWinApp you can use GetFirstDocTemplatePosition and
GetNextDocTemplate to enumerate the document templates, then use
GetFirstDocPosition and GetNextDoc to enumerate the documents.

Dave
--
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sun, 19 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Doc pointer in the MainFrame

2. Getting a pointer to the DOC view frame in the DOC

3. Getting a pointer to the DOC view frame in the DOC

4. Accessing MainFrame from Doc

5. Q: What event follows doc creation and mainframe and menu init

6. (WTL) Get pointer to view from mainframe?

7. POINTER TO MAINFRAME

8. Forwarding Msg Mainframe -> Doc/MenuClick treated in Doc

9. Forwarding Msg Mainframe -> Doc/MenuClick treated in Doc

10. Changing doc pointer between TListView objects

11. Q: Pointer to Doc from MainFrm, and dynamic Forms

12. Pointer to Doc works in one app but not another

 

 
Powered by phpBB® Forum Software