Export (0) Print
Expand All

GetOpenFileNameEx

Windows Mobile 6.5
4/8/2010

This function creates a system-defined dialog box that shows a grid of thumbnails, enabling the user to choose a picture or video.


BOOL GetOpenFileNameEx(
  LPOPENFILENAMEEX lpofn
);

lpofn

[in] Pointer to an OPENFILENAMEEX structure that contains information used to initialize the dialog. When GetOpenFileNameEx returns, this structure contains information about the user's file selection.

Nonzero indicates that the user specified a file name. The buffer pointed to by the lpstrFile member of the OPENFILENAMEEX structure contains the full path and filename specified by the user.

Zero indicates that the user canceled or closed the dialog or that an error occurred. To get extended error information, call GetLastError function. Error values which may be returned include:

Return Value Description

ERROR_SUCCESS

The user canceled the dialog.

ERROR_OUTOFMEMORY

Operation ran out of memory.

ERROR_INVALID_PARAMETER

An invalid argument was specified.

ERROR_INSUFFICIENT_BUFFER

This error indicates that the buffer pointed to by lpstrFile was too small. In this case, the first two bytes of the buffer contain the required buffer size in characters.

ERROR_RESOURCE_DISABLED

This error indicates that the camera is disabled due to a specific condition value.

The following code example demonstrates how to use GetOpenFileNameEx.

Bb431734.note(en-us,MSDN.10).gifNote:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
BOOL UseFilePicker(HWND hwndOwner)
{
    TCHAR    szFile[MAX_PATH];
    OPENFILENAMEEX  ofnex = {0};
    ofnex.lStructSize     = sizeof(ofnex);
    ofnex.hwndOwner       = hwndOwner;
    ofnex.lpstrFile       = szFile;
    ofnex.nMaxFile        = sizeof(szFile)/sizeof(szFile[0]);
    ofnex.lpstrFilter     = TEXT("All Files (*.*)\0*.*\0");
    ofnex.lpstrTitle      = TEXT("Thumbnail View");
    // Show thumbnails of files that are not DRM protected
    ofnex.ExFlags         = OFN_EXFLAG_THUMBNAILVIEW | OFN_EXFLAG_HIDEDRMPROTECTED;
    ofnex.lpstrInitialDir = NULL;
}

The following code example displays a dialog in which the user may select only files of type '*.BMP'. The function returns TRUE if the user selects a file, and the buffer is set to the full path and name of the selected file. If the function returns FALSE, the contents of the buffer are undefined.

Bb431734.note(en-us,MSDN.10).gifNote:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
BOOL SelectBMP(LPTSTR pszFilename, DWORD cchBufSize)
{
  ASSERT(pszFilename);
  OPENFILENAMEEX ofn = {0};
  ofn.lStructSize     = sizeof(ofn);
  ofn.lpstrFilter     = _T("BMP Files (*.bmp)\0*.bmp\0");
  ofn.lpstrFile       = pszFilename;
  ofn.nMaxFile        = cchBufSize;
  ofn.lpstrInitialDir = _T("\\Program Files\\MyApp");
  ofn.lpstrTitle      = _T("Select a bitmap");
  ofn.ExFlags         = OFN_EXFLAG_THUMBNAILVIEW;
  return GetOpenFileNameEx(&ofn));
}

Headeraygshell.h
Windows MobilePocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

Community Additions

ADD
Show:
© 2014 Microsoft