LImageListControl::GetSelectCount

#include "ltwrappr.h"

L_INT LImageListControl::GetSelectCount(L_VOID)

Gets the current number of selected items in the ImageList Control.

Returns

>= 0

The number of selected items.

<0

An error occurred. Refer to Return Codes.

Comments

Call this function, before calling LImageListControl::GetSelectedItems, to get the number of selected items. You can then use this number for allocating storage for the LILITEM structures.

Required DLLs and Libraries

LTDIS
LTFIL
LTIMG

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

Platforms

Win32, x64.

See Also

Functions:

Class Members

Topics:

Using the ImageList Control

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LImageListControl__GetSelectCountExample(HWND hParent)
{
   L_INT nRet;
   LImageListControl m_ImgList;
   L_INT nCount;
   LILITEM Item;
   LBitmapBase Bitmap;
   if(m_ImgList.CreateControl(hParent,0) == NULL)
      return FAILURE;
   // insert an item to image list control and set it as selected
   nRet = Bitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp")));
   Item.uStructSize = sizeof(LILITEM);
   Item.pBitmap = Bitmap.GetHandle();
   Item.pText = MAKE_IMAGE_PATH(TEXT("image1.cmp"));
   Item.lData = 0;
   Item.bSelected = TRUE;
   Item.uMask = LILITEM_BITMAP | LILITEM_TEXT | LILITEM_DATA | LILITEM_SELECTED;
   nRet = m_ImgList.Insert(&Item);// at end of list
   // get selected count
   nCount = m_ImgList.GetSelectCount();
   if(nCount>0)
   {
      pLILITEM pItems=NULL;
      pItems = (pLILITEM)GlobalAlloc(GMEM_MOVEABLE, sizeof(LILITEM)*nCount);
      pItems->uStructSize = sizeof(LILITEM);
      pItems->uBitmapStructSize = sizeof(BITMAPHANDLE);
      if(pItems)
      {
         // get the selected items
         nRet = m_ImgList.GetSelectedItems(pItems);
         if(nRet < 0)
            return nRet;
         L_INT x;
         CString csOut;
         csOut.Format(TEXT("%ld items selected!"), nCount);
         AfxMessageBox(csOut);
         for(x=0; x<nCount; x++)
         {
            csOut.Format(TEXT("Item#%ld with text=%s"), pItems[x].lIndex, pItems[x].pText);
            AfxMessageBox(csOut);
         }
         GlobalFree(pItems);
      }
   }
   return SUCCESS;
}