LImageListControl::GetSelectCount

Summary

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

Syntax

#include "ltwrappr.h"

L_INT LImageListControl::GetSelectCount(L_VOID)

Returns

Value Meaning
>= 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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.