Link to home
Start Free TrialLog in
Avatar of mosaicer
mosaicer

asked on

Opening a file passed on command line

How do I go about automatically opening a file that was passed on
the command line?

I have a menu item File->Open with ID_FILE_OPEN but don't know
how to simulate a user having clicked on this.  I'm trying
to write some code in the Application InitInstance.

Can I send some sort of a message and have my routine for
ID_FILE_OPEN execute?  (The routine sits in my document class)
Is there a way to directly call my OnFileOpen routine from my
application class?

Maybe there's a better way to accomplish what I'm trying to do?

ASKER CERTIFIED SOLUTION
Avatar of tvanceplus
tvanceplus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mosaicer
mosaicer

ASKER

Thanks!
I'm having problems implementing this
solution as I'm unable to call
beginning() from my application
class.  Something about an
illegal call to a static member
function.

Sorry, I forgot to put in that part.
Map a message  to the message OnInitialUpdate() in your CView class;
In that function add this.

void CMyView::OnInitialUpdate(){
 CMyDocument* doc=(CMyDocument*)
     GetDocument();

 doc->beginning();
}

Sorry for not getting this in the answer.

Good Luck!

tvanceplus
Thank you very much!  This was
the last thing I had to do to finish
up this project. Yay!