Solved

CWinApp::OnFileOpen();

Posted on 2001-09-06
8
1,395 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
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 20 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
Question regarding Copy/Paste 16 91
Turn a spreadsheet into a vba executable. 2 79
matchUp  challenge 9 94
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

19 Experts available now in Live!

Get 1:1 Help Now