L_DlgOpen

#include "l_bitmap.h"

L_LTDLG_API L_INT L_DlgOpen(hWndOwner, pOpenFileName, pDlgParams)

Displays the Open dialog box, and gets the options for L_LoadFile.

Parameters

L_HWND hWndOwner

Handle of the window, which owns the dialog.

LPOPENFILENAMEW pOpenFileName

Windows structure. This structure is documented in the Microsoft Windows SDK documentation.

For this function, you must set the following members of the OPENFILENAMEW structure:

lStructSize 
lpstrFilter 
nFilterIndex 
lpstrFile 
nMaxFile 
lpstrFileTitle 
nMaxFileTitle 
lpstrInitialDir 
lpstrTitle 
lpstrDefExt 
Flags 

LEADTOOLS specifically sets the following flags:

LPOPENDLGPARAMS pDlgParams

Pointer to a OPENDLGPARAMS structure to be updated with the values entered by the user through the dialog. Set members of this structure, before calling this function, to set the dialogs initial values.

Comments

The Open dialog.

✎ NOTE

In the Files of type, the file types listed below are only supported in 32-bit platforms:

  • Canon RAW Format (*.crw)
  • DJVU (*.djv)
  • Kodak Digital Camera KDC (*.kdc)
  • Kodak Photo CD (*.pcd)
  • Profession Digital Camera (*.dcr)

Returns

Value Meaning
SUCCESS_DLG_OK The "OK" button was pressed, and the dialog exited successfully.
SUCCESS_DLG_CANCEL The "Cancel" button was pressed, and the dialog exited successfully.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT EXT_CALLBACK FileLoadCallback(LPOPENDLGFILEDATA lpFileData, 
                                    L_INT             nTotalPercent, 
                                    L_INT             nFilePercent, 
                                    L_VOID*           lpUserData) 
{ 
   UNREFERENCED_PARAMETER(lpUserData); 
   if ( nFilePercent == 100 ) 
   { 
      MessageBox ( NULL, lpFileData->szFileName, TEXT("File Loaded"), MB_OK ) ; 
   } 
 
   if ( nTotalPercent == 100 ) 
   { 
      MessageBox ( NULL, TEXT("File(s) Loading Completed"), TEXT("File(s) Loaded"), MB_OK ) ; 
   } 
 
   return SUCCESS ; 
} 
 
L_INT DlgOpenExample(HWND hWnd) 
{ 
   OPENFILENAME  OpenFileName; 
   OPENDLGPARAMS DlgParams ; 
   L_INT         nRet ; 
 
   memset ( &OpenFileName, 0, sizeof ( OPENFILENAME ) ) ; 
   memset ( &DlgParams, 0, sizeof ( OPENDLGPARAMS ) ) ; 
 
   OpenFileName.lStructSize       = sizeof(OPENFILENAME); 
   OpenFileName.lpstrInitialDir   = NULL; 
   OpenFileName.Flags             = OFN_EXPLORER         | 
                                    OFN_ALLOWMULTISELECT ; 
 
   DlgParams.uStructSize = sizeof ( OPENDLGPARAMS ) ; 
   DlgParams.pfnFileLoadCallback = FileLoadCallback ; 
 
   DlgParams.uDlgFlags = DLG_OPEN_SHOW_PROGRESSIVE     | 
                         DLG_OPEN_SHOW_MULTIPAGE       | 
                         DLG_OPEN_SHOW_LOADROTATED     | 
                         DLG_OPEN_SHOW_LOADCOMPRESSED  | 
                         DLG_OPEN_SHOW_FILEINFO        | 
                         DLG_OPEN_SHOW_PREVIEW         | 
                         DLG_OPEN_SHOW_DELPAGE         | 
                         DLG_OPEN_SHOW_LOADOPTIONS     | 
                         DLG_OPEN_VIEWTOTALPAGES       | 
                         DLG_OPEN_LOADBITMAP           | 
                         DLG_OPEN_GENERATETHUMBNAIL    ; 
 
   nRet = L_DlgInit ( DLG_INIT_COLOR ) ; 
   if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED) 
      return nRet; 
 
   nRet = L_DlgOpen ( hWnd, &OpenFileName, &DlgParams ); 
 
   if ( SUCCESS_DLG_OK == nRet ) 
   { 
      int i = 0 ; 
 
      // After using the return data you should free allocated data 
      for ( i = 0 ; i < DlgParams.nNumOfFiles ; i++ ) 
      { 
         if ( NULL != DlgParams.pFileData [ i ].pBitmap ) 
         { 
            if ( DlgParams.pFileData [ i ].pBitmap->Flags.Allocated ) 
            { 
               L_FreeBitmap( DlgParams.pFileData [ i ].pBitmap ) ; 
            } 
 
            GlobalFree ( DlgParams.pFileData [ i ].pBitmap ) ; 
         } 
 
         if ( NULL != DlgParams.pFileData [ i ].pThumbnail ) 
         { 
            if ( DlgParams.pFileData [ i ].pThumbnail->Flags.Allocated ) 
            { 
               L_FreeBitmap( DlgParams.pFileData [ i ].pThumbnail ) ; 
            } 
 
            GlobalFree ( DlgParams.pFileData [ i ].pThumbnail ) ; 
         } 
 
         if ( NULL != DlgParams.pFileData [ i ].pFileInfo ) 
         { 
            GlobalFree ( DlgParams.pFileData [ i ].pFileInfo ) ; 
         } 
 
         if ( NULL != DlgParams.pFileData [ i ].FileOptions.pOptions ) 
         { 
            GlobalFree ( DlgParams.pFileData [ i ].FileOptions.pOptions ) ; 
         } 
      } 
 
      if ( NULL != DlgParams.pFileData ) 
      { 
         GlobalFree ( DlgParams.pFileData ) ; 
      } 
   } 
   else 
      return nRet; 
 
   nRet = L_DlgFree(); 
   return nRet; 
} 
Help Version 20.0.2019.9.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Common Dialog C API Help