[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

CWinApp::OnFileOpen();

Posted on 2001-09-06
8
Medium Priority
?
1,488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6460706
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 80 total points
ID: 6461237
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
ID: 6461304
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6463077
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
 
LVL 10

Expert Comment

by:makerp
ID: 6463225
do

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

Expert Comment

by:Triskelion
ID: 6463772
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
ID: 6464283
and your point is!, have i proposed an answer, no. besides my code is easier
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6464621
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

650 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