Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS Common Dialog C DLL Help

L_DlgOpen

Show in webframe

#include "l_bitmap.h"

L_LTDLG_API L_INT L_DlgOpen(hWndOwner, pOpenFileName, pDlgParams)

L_HWND hWndOwner;

/* owner of dialog */

LPOPENFILENAMEW pOpenFileName;

/* pointer to a Windows OPENFILENAMEW structure */

LPOPENDLGPARAMS pDlgParams;

/* pointer to a structure */

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

Parameter

Description

hWndOwner

Handle of the window, which owns the dialog.

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:

 

OFN_HIDEREADONLY

 

OFN_ENABLEHOOK

 

OFN_ENABLETEMPLATE

 

OFN_ALLOWMULTISELECT is not set by LEADTOOLS automatically, but is allowed.

 

OFN_SHOWHELP is set only if you specify a HELP callback (that is pfnCallback was not NULL).

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:

Returns

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

LTDLGFILE
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTFIL
LTDIS
LTIMG
LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_DlgInit, L_LoadFile, L_LoadBitmap

Topics:

Dialogs: Maintenance and General Use

 

Using Imaging Common Dialog

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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.