Solved

CWinApp::OnFileOpen();

Posted on 2001-09-06
8
1,373 Views
Last Modified: 2013-11-20
CWinApp::OnFileOpen();

Is a standard function to open a file!
The function itself does not open the file, but returns a path string Right ?, where is that string returned ?

How does OnFileOpen work ?
0
Comment
Question by:win32
8 Comments
 
LVL 2

Expert Comment

by:BogdyPtr
Comment Utility
The OnOpenFile is suposed to be use with SDI/MDI applications. The OnOpenFile displays an open file dialog, gets the file name and calls the CWinApp::OnOpenDocument with the file path chosed by user.
0
 
LVL 6

Accepted Solution

by:
Triskelion earned 20 total points
Comment Utility
CWinApp::OnFileOpen
afx_msg void OnFileOpen( );

It is void.  It does not return anything.

From the looks of it, it's stored in a
dlgFile.m_ofn.lpstrFile
that can be retrieved from the
CFileDialog::GetFileName() function.
0
 
LVL 6

Expert Comment

by:Triskelion
Comment Utility
You need to override the OnFileOpen.
I chose (for this example) to do it in the View, but it can be done anywhere the ID_FILE_OPEN message is passed.

void CMy20179379View::OnFileOpen()
{
     CFileDialog     xDlg
          (
          TRUE, //BOOL bOpenFileDialog,
          NULL, //LPCTSTR lpszDefExt = NULL,
          NULL, //LPCTSTR lpszFileName = NULL,
          (OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT),// DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
          "*.exx",//LPCTSTR lpszFilter = NULL,
          NULL//CWnd* pParentWnd = NULL
          );
     xDlg.DoModal();
     AfxMessageBox(xDlg.GetFileName());
}
0
 
LVL 3

Expert Comment

by:GGRUNDY
Comment Utility
Have a look at CFile::Open.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cfile.3a3a.open.asp

I just have a suspicion this is what you are really after.

Apologies if I am wrong.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:makerp
Comment Utility
do

CFileDialog *dlg;
*dlg = new........
dlg->DoModal();
CString MyFileName = dlg->GetPathName();
0
 
LVL 6

Expert Comment

by:Triskelion
Comment Utility
markp, that's practically what I said except I didn't use a pointer to create the dialog box and I used AfxMessageBox to display the string.
0
 
LVL 10

Expert Comment

by:makerp
Comment Utility
and your point is!, have i proposed an answer, no. besides my code is easier
0
 
LVL 6

Expert Comment

by:Triskelion
Comment Utility
The code I posted shows all of the parameters for customizing the CFileDialog at creation.

I copied that directly from a test app.
There is no 'easier' concept involved with either of our examples.  You've confused me.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now