ExportBitmapList example for C++ Builder

void __fastcall TForm1::btnExportBitmapListClick(TObject *Sender)
{
   int nRet;
   HBITMAPLIST hExportedBitmapList;

   // Check if the ImageList control has more than 4 images.
   if(LEADImgList1->Count > 4)
   {
      nRet= LEADImgList1->ExportBitmapList (1, 2, hExportedBitmapList);
      if(nRet == SUCCESS)
      {
         // Check if the hExportedBitmapList updated successfully.
         if(hExportedBitmapList != 0)
         {
            LEADImage1->BitmapList = hExportedBitmapList;
         }
      }
      else
         ShowMessage("Error: " + IntToStr(nRet));
   }
   else
      ShowMessage("Try to add more files to the image list control");
}