windows_programming_notes.nbk: Home | Index | Next Page: GetParent | Previous Page: GetMessage


 GetOpenFileName

The GetOpenFileName function creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open.

Syntax

    BOOL GetOpenFileName(  
        LPOPENFILENAME lpofn
    );

Parameters

Return Value

If the user specifies a file name and clicks the OK button, the return value is nonzero. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.

If the user cancels or closes the Open dialog box or an error occurs, the return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the following values.

Remarks

The Explorer-style Open dialog box provides user-interface features that are similar to the Microsoft Windows Explorer. You can provide an [OFNHookProc] hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the address of the hook procedure in the lpfnHook member.

Windows continues to support the old-style Open dialog box for applications that want to maintain a user-interface consistent with the old-style user-interface. To display the old-style Open dialog box, enable an [OFNHookProcOldStyle] hook procedure and ensure that the OFN_EXPLORER flag is not set.

To display a dialog box that allows the user to select a directory instead of a file, call the SHBrowseForFolder function.

Note, when selecting multiple files, the total character limit for the file names depends on the operating system and the version of the function.

Windows 95/98/Me: GetOpenFileNameW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .

Function Information


windows_programming_notes.nbk: Home | Index | Next Page: GetParent | Previous Page: GetMessage


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time