Home > Software engineering >  How to open file dialog box directly open the root directory
How to open file dialog box directly open the root directory

Time:10-09

I now have open file dialog box in the program, but each is opened recently open file folder, procedure is as follows, excuse me what method can open, open the root directory directly, thank you!!!!!
 
TCHAR szFilter []=_T (" ABC file (*. BIN) | *. BIN; *. BIN | | ");
CFileDialog fileDlg (TRUE, _T (" (*. BIN) | *. BIN "), NULL, OFN_HIDEREADONLY, szFilter, NULL);//construct open file dialog box

CodePudding user response:

CFileDialog Class Members
The Data Members

M_ofn The Windows OPENFILENAME structure. Provides access to basic file dialog box parameters.
OPENFILENAME
The OPENFILENAME structure contains information that The GetOpenFileName and GetSaveFileName functions provides The use to initialize an Open or Save As common dialog box. After The user closes The dialog box, The system returns information about The user 's selection in this structure.

Typedef struct tagOFN {//ofn
DWORD lStructSize;
The HWND hwndOwner;
HINSTANCE HINSTANCE,
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
DWORD lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} OPENFILENAME;

CodePudding user response:

reference 1st floor zhao4zhong1 response:
CFileDialog Class Members
The Data Members

M_ofn The Windows OPENFILENAME structure. Provides access to basic file dialog box parameters.
OPENFILENAME
The OPENFILENAME structure contains information that The GetOpenFileName and GetSaveFileName functions provides The use to initialize an Open or Save As common dialog box. After The user closes The dialog box, The system returns information about The user 's selection in this structure.

Typedef struct tagOFN {//ofn
DWORD lStructSize;
The HWND hwndOwner;
HINSTANCE HINSTANCE,
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
DWORD lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} OPENFILENAME;
could you please tell me how to write the program? Beginners do not understand,

CodePudding user response:

For example,
FileDlg. M_ofn. LpstrInitialDir=_T (" D: \ \ ");

CodePudding user response:

reference zhao4zhong1 reply: 3/f
such as
FileDlg. M_ofn. LpstrInitialDir=_T (" D: \ \ ");
so why not?
 
TCHAR szFilter []=_T (" ABC file (*. BIN) | *. BIN; *. BIN | | ");
CFileDialog fileDlg (TRUE, _T (" (*. BIN) | *. BIN "), NULL, OFN_HIDEREADONLY, szFilter, NULL);//construct open file dialog box
FileDlg. M_ofn. LpstrInitialDir=_T (" D: \ \ ");

CodePudding user response:

The Collapse AllExpand All Code: All Code: Multiple Code: Visual Basic Code: c # Code: Visual c + + Code: j # Code: JScript
Visual Basic
C #
Visual c + +
J #
JScript
MFC Library Reference
CFileDialog Class
See Also the Send Feedback


Encapsulates the common file dialog box for Windows.


The class CFileDialog: public CCommonDialog


Few
Common file dialog boxes dojo.provide an easy way to implement the file Open and file Save As dialog boxes, and other file - selection dialog boxes) in a manner consistent with Windows standards.

You can use CFileDialog as is with the constructor provided, or You can derive your own dialog class from CFileDialog and write a constructor to suit your needs. In either case, these dialog boxes will concerns like standard MFC dialog boxes because they are derived from the CCommonDialog class.

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related