Name

OPENFILENAME

Synopsis

Defines the Open and Save As common dialog boxes:

Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    pvReserved As Long
    dwReserved As Long
    FlagsEx As Long
End Type

Structure Members

lStructSize

Size of this structure. You should set it to Len(OPENFILENAME).

hwndOwner

The handle of the dialog’s owning window. Can be if no window owns this dialog.

hInstance

The handle to the object that contains the dialog template resource. If the dialog template resource resides in a DLL, use the LoadLibrary API function. The function takes one parameter, the path and filename of the DLL. LoadLibrary returns the handle to the DLL.

lpstrFilter

A string defining the filters, if any, used in the dialog box’s Save As Type drop-down list. The filter is in the format {filter name}|{filter}. The filter name is a name for the filter such as “All Files”. The filter is an expression used to describe the filter, such as “*.*”. Therefore, the code to describe this filter would look like the following:

OPENFILENAME.lpstrFilter = "AllFiles | *.*"
lpstrCustomFilter

Contains the last filter chosen ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.