L_ILM_GETSELITEMS

Send this message to get the currently selected items in the ImageList Control.

Parameter

Description

wParam

Ignored, use 0.

lParam

Pointer to a caller-allocated array of LILITEM structures to be filled with the selected items.

Returns

>=0

The number of items currently selected and pointed to by lParam

< 0

An error occurred. Refer to Return Codes.

Comments

The return value is the number of items pointed to by lParam.

You must set the uStructSize member of the LILITEM structure before using this message.

If you are including the LILITEM_BITMAP flag in the uMask member of the LILITEM structure, you must set the uBitmapStructSize member of the LILITEM structure before using this message.

You must allocate the array to be large enough to hold the selected items and free the memory when it is no longer needed by your application.

If you pass NULL for lParam, the message will simply return the current number of selected items.

The LILITEM structure for each selected item will contain all attributes for the item. The lIndex member of the structure will contain the 0-based index of the item.

The associated macro is:

L_ImgListGetSelItems(hWnd, pItem)

For a complete list of available macros, refer to the Ltlst.h file.

See Also

Elements:

L_ILM_GETSELCOUNT, L_ILM_GETROWCOUNT, L_ILM_GETCOLCOUNT, L_ILM_GETITEMCOUNT, L_ILM_GETPAGECOUNT, L_ILM_GETITEM, L_ILM_SETITEM

Topics:

Using the ImageList Control

 

Image List Control Messages

Example

L_VOID TestFunc16(HWND hWnd)
{
   LRESULT lRet;
   L_TCHAR szText[200];
   L_TCHAR szMsg[200];
   pLILITEM pItems=NULL;
   pLILITEM pTemp=NULL;
   L_INT32 x;

   if(IsWindow(hWnd))
   {
      /* Get selected item count */
      lRet = SendMessage(hWnd, L_ILM_GETSELITEMS, 0, 0L);
      if(lRet > 0)
      {
         /* allocate the storage */
         pItems = (pLILITEM)malloc(lRet * sizeof(LILITEM));
         memset(pItems, 0, lRet * sizeof(LILITEM));
         pTemp = pItems;
         for(x=0; x<lRet; x++)
         {
            pTemp->uStructSize = sizeof(LILITEM);
            pTemp->uBitmapStructSize = sizeof(BITMAPHANDLE);
         }
         /* Get selected items */
         lRet = SendMessage(hWnd, L_ILM_GETSELITEMS, 0, (LPARAM)pItems);

         pTemp = pItems;
         lstrcpy(szMsg, TEXT(""));
         if(pItems)
         {
            for(x=0;x<lRet;x++)
            {
               wsprintf(szText, TEXT("%s at index %ld\n"), pTemp->pText, pTemp->lIndex);
               lstrcat(szMsg, szText);
               pTemp++;
            }
            /* free the storage */
            free(pItems);
         }
         MessageBox(hWnd, szMsg, TEXT("Selected Items"), MB_OK);
      }
      else
         MessageBox(hWnd, TEXT("None"), TEXT("Selected Items"), MB_OK);
   }
}