Gets the current number of selected items in the ImageList Control.
#include "ltwrappr.h"
L_INT LImageListControl::GetSelectCount(L_VOID)
Value | Meaning |
---|---|
>= 0 | The number of selected items. |
<0 | An error occurred. Refer to Return Codes. |
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.
Win32, x64.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document