LDialogImageEffect::DoModalAddBitmaps

#include "ltwrappr.h"

virtual L_INT LDialogImageEffect::DoModalAddBitmaps(hWndOwner)

HWND hWndOwner;

/* handle of the window which owns the dialog */

Displays the Add Bitmaps dialog box, and gets the options for LBitmapBase::Add .

Parameter

Description

hWndOwner

Handle of the window which owns the dialog.

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.

Comments

LDialogImageEffect::SetAddBitmapsParams must be called before using this function to set the initial values for the dialog. You can get the updated ADDBITMAPSDLGPARAMS with the values entered by the user through the dialog by using LDialogImageEffect::GetAddBitmapsParams.

The Add Bitmaps dialog.

Required DLLs and Libraries

LTDLGIMGEFX
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTDIS
LTIMGUTL
LTIMGCLR

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:

LDialogBase::Initialize, LBitmapBase::Add , LBase::EnableCallBack , LDialogBase::EnablePreview, LDialogBase::EnableAutoProcess, LDialogBase::EnableToolbar, LDialogBase::Free, LDialogImageEffect::SetAddBitmapsParams, LDialogImageEffect::GetAddBitmapsParams

Topics:

Using Imaging Common Dialog

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LDialogImageEffect_DoModalAddBitmapsExample(LBitmap * pBitmap, HWND hWnd)
{
   L_INT nRet;
   ADDBITMAPSDLGPARAMS DlgParams;
   DLGBITMAPLISTITEM   BitmapListItems [ 3 ];
   DLGBITMAPLIST       BitmapList;
   LBitmap TmpBitmap1, TmpBitmap2, TmpBitmap3;
   L_INT               i;
   LDialogImageEffect DlgImageEffect;
    DlgImageEffect.SetBitmap(pBitmap);
   memset ( &DlgParams, 0, sizeof ( ADDBITMAPSDLGPARAMS ) );
   // ITEM (1)
   BitmapListItems [ 0 ].pszFileName = ( L_TCHAR * ) malloc ( sizeof ( L_TCHAR ) * 20 );
   BitmapListItems [ 0 ].pBitmap    = ( pBITMAPHANDLE ) malloc ( sizeof ( BITMAPHANDLE ) );
   nRet = TmpBitmap1.Load (MAKE_IMAGE_PATH(TEXT("sample1.cmp")), 
                  LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_COMPRESSED, 
                  ORDER_BGR, 
                  NULL, 
                  NULL );
   if(nRet != SUCCESS)
      return nRet;
   lstrcpy ( BitmapListItems [ 0 ].pszFileName, MAKE_IMAGE_PATH(TEXT("sample1.cmp") ));
   BitmapListItems [ 0 ].pBitmap = TmpBitmap1.GetHandle();
   // ITEM (2)
   BitmapListItems [ 1 ].pszFileName = ( L_TCHAR * ) malloc ( sizeof ( L_TCHAR ) * 20 );
   BitmapListItems [ 1 ].pBitmap    = ( pBITMAPHANDLE ) malloc ( sizeof ( BITMAPHANDLE ) );
   lstrcpy ( BitmapListItems [ 1 ].pszFileName, MAKE_IMAGE_PATH(TEXT("sample2.cmp")));
   nRet = TmpBitmap2.Load(MAKE_IMAGE_PATH(TEXT("sample2.cmp")), 
                          LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_COMPRESSED, 
                          ORDER_BGR, 
                          NULL, 
                          NULL );
   if(nRet != SUCCESS)
      return nRet;
   BitmapListItems [ 1 ].pBitmap = TmpBitmap2.GetHandle ();
   // ITEM (3)
   BitmapListItems [ 2 ].pszFileName = ( L_TCHAR * ) malloc ( sizeof ( L_TCHAR ) * 20 );
   BitmapListItems [ 2 ].pBitmap    = ( pBITMAPHANDLE ) malloc ( sizeof ( BITMAPHANDLE ) );
   lstrcpy ( BitmapListItems [ 2 ].pszFileName, MAKE_IMAGE_PATH(TEXT("sample3.cmp")));
   nRet = TmpBitmap3.Load (MAKE_IMAGE_PATH(TEXT("sample3.cmp")), 
                           LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_COMPRESSED, 
                           ORDER_BGR, 
                           NULL, 
                           NULL );
   if(nRet != SUCCESS)
      return nRet;
   BitmapListItems [ 2 ].pBitmap = TmpBitmap3.GetHandle ();
   BitmapList.nCount      = 3;
   BitmapList.pBitmapList = ( LPDLGBITMAPLISTITEM ) &BitmapListItems; 
   DlgParams.pBitmapList      = &BitmapList;
   DlgParams.uAddBitmapsFlags = BC_AVG;
   nRet = LDialogBase::Initialize( 0 );
   if(nRet != SUCCESS)
      return nRet;
   DlgImageEffect.EnableCallBack(FALSE);
   DlgImageEffect.EnablePreview(TRUE);
   DlgImageEffect.EnableAutoProcess(TRUE);
   DlgImageEffect.EnableToolbar(TRUE);
   nRet = DlgImageEffect.SetAddBitmapsParams(&DlgParams);
   if(nRet != SUCCESS)
      return nRet;
   nRet = DlgImageEffect.DoModalAddBitmaps(hWnd);
   if(nRet < 1)
      return nRet;
   //Gets the updated struct value.
   nRet = DlgImageEffect.GetAddBitmapsParams(&DlgParams, sizeof(DlgParams));
   if(nRet != SUCCESS)
      return nRet;
   nRet = LDialogBase::Free ( );
   if(nRet != SUCCESS)
      return nRet;
   // Clean up memory
   for ( i = 0; i < 3; i++ )
   {
      if ( NULL != BitmapListItems [ i ].pBitmap )
      {
         free ( BitmapListItems [ i ].pBitmap );
      }
      
      if ( NULL != BitmapListItems [ i ].pszFileName )
      {
         free ( BitmapListItems [ i ].pszFileName );
      }
   }
   return SUCCESS;
}