When I place there are 16 images on the folder I obtain there are 10 buttons for select an image. When I place there are 68 images on the folder I obtain there are 15 buttons for select an image.
This quantity of buttons I retrieve before code changing and after code changing .
CUserBitmapWin m_Image;(Class CUserBitmapWin in the attached file)
int OnStitch()
{
ActionName = "Stitch";
int nRet = SUCCESS_DLG_OK ;
GETDIRECTORYDLGPARAMS DirectoryDlgParams ;
ZeroMemory ( &DirectoryDlgParams, sizeof (GETDIRECTORYDLGPARAMS)) ;
DirectoryDlgParams.uStructSize = sizeof (GETDIRECTORYDLGPARAMS);
DirectoryDlgParams.pszDirectory = (L_TCHAR *) malloc ( L_MAXPATH * 2 ) ;
DirectoryDlgParams.pszTitle = _T("Select Images Folder") ;
DirectoryDlgParams.nBuffSize = L_MAXPATH ;
DirectoryDlgParams.pszFilter = NULL ;
DirectoryDlgParams.nFilterIndex = 1 ;
m_Image.DialogFile()->SetDirectoryParams(&DirectoryDlgParams) ;
nRet = m_Image.DialogFile()->DoModalGetDirectory ( hWnd) ;
int imgCount =1000;
// Get the directory
if ( nRet == SUCCESS_DLG_OK )
{
DLGBITMAPLIST BitmapList ;
L_INT i = 0 ;
HCURSOR hCursor;
hCursor = SetCursor (LoadCursor (NULL, IDC_WAIT));
BitmapList.pBitmapList = (DLGBITMAPLISTITEM *) malloc ( sizeof ( DLGBITMAPLISTITEM ) * imgCount ) ;
//BitmapList.nCount = imgCount;
if ( NULL == BitmapList.pBitmapList )
{
SetCursor (hCursor);
return FAILURE;
}
else
{
for ( i = 0 ; i < imgCount ; i++ )
{
BitmapList.pBitmapList [ i ].pBitmap = (BITMAPHANDLE *) malloc ( sizeof ( BITMAPHANDLE ) ) ;
BitmapList.pBitmapList [ i ].pszFileName = (L_TCHAR *) malloc ( sizeof ( L_TCHAR ) * L_MAXPATH ) ;
BitmapList.pBitmapList [ i ].pszDescription = (L_TCHAR *) malloc ( sizeof ( L_TCHAR ) * L_MAXPATH ) ;
memset(BitmapList.pBitmapList [ i ].pBitmap,0, sizeof(BITMAPHANDLE));
memset(BitmapList.pBitmapList [ i ].pszFileName,0, sizeof ( L_TCHAR ) * L_MAXPATH );
memset(BitmapList.pBitmapList [ i ].pszDescription,0, sizeof ( L_TCHAR ) * L_MAXPATH );
}
}
int t = BitmapList.nCount;
if ( 1/*SUCCESS*/ == ( nRet = GenerateBitampList ( DirectoryDlgParams.pszDirectory, &BitmapList, FALSE )) )
{
STITCHDLGPARAMS DlgParams;
memset ( &DlgParams, 0, sizeof ( STITCHDLGPARAMS ) ) ;
DlgParams.uStructSize = sizeof ( STITCHDLGPARAMS );
DlgParams.nResultingBitmapWidth = 320 ;
DlgParams.nResultingBitmapHeight = 200 ;
DlgParams.nResultingBitmapBitsPerPixel = 24 ;
DlgParams.nRes = 72 ;
DlgParams.crBackGround = RGB ( 255, 255, 255 ) ;
DlgParams.pBitmapList = &BitmapList ;
DlgParams.uDlgFlags = 0 ;
DlgParams.nCmdShow = SW_SHOW ;
m_Image.DialogImageEffect()->EnableCallBack(FALSE);
m_Image.DialogImageEffect()->SetStitchParams(&DlgParams) ;
SetCursor (hCursor);
L_INT nTtt = m_Image.DialogImageEffect()->DoModalStitch(hWnd);
if (nTtt == 103) return 0;
}
else
SetCursor (hCursor);
// clean up
for ( i = 0 ; i < imgCount ; i++ )
{
if ( NULL != BitmapList.pBitmapList [ i ].pBitmap )
{
if ( BitmapList.pBitmapList [ i ].pBitmap->Flags.Allocated )
{
LBitmap MyTmpBtmp;
MyTmpBtmp.SetHandle(BitmapList.pBitmapList [ i ].pBitmap);
MyTmpBtmp.Free();
}
free ( BitmapList.pBitmapList [ i ].pBitmap ) ;
}
if ( NULL != BitmapList.pBitmapList [ i ].pszFileName )
{
free ( BitmapList.pBitmapList [ i ].pszFileName ) ;
}
if ( NULL != BitmapList.pBitmapList [ i ].pszDescription )
{
free ( BitmapList.pBitmapList [ i ].pszDescription ) ;
}
}
if ( NULL != BitmapList.pBitmapList )
{
free ( BitmapList.pBitmapList ) ;
}
if ( nRet == 0 ) return 0;
return SUCCESS_DLG_OK ;
}
else
{
return FAILURE;
}
}