|
-
February 19th, 2004, 10:17 PM
#1
Open a file by using DialogBox
When we push the button of "open file", it always show a window to let us select file. Now I want to open this window by pushing a button in DialogBox. How can I do it?
I know CWinApp::OnFileOpen() can open file, but I don't know how to do in detail. Please help me !!
Thanks a lot !!
programming environment: VC 6.0:
-
February 19th, 2004, 10:32 PM
#2
Do you want any functionality or something?
What I usually do is create a button and:
Code:
OPENFILENAME ofn = {0};
char szName[MAX_PATH];
*szName = 0;
CString transfile1;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = AfxGetApp()->m_pMainWnd->m_hWnd;
ofn.lpstrFilter = NULL;
ofn.lpstrFilter = "Exe files (*.exe)\0*.exe\0All files (*.*)\0*.*\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = &szName[0];
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = NULL;
//m_DefaultDir;
ofn.lpstrTitle = "Open Executable File";
ofn.lpstrFileTitle = NULL;
ofn.lpstrDefExt = "TXT";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER;
GetOpenFileName(&ofn);
and then I do whatever (be it execute the file, store the folder path, etc.).
Last edited by eagle1; February 19th, 2004 at 10:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|