ImageEn, unit iexAcquire

DrawAcquireComboListBoxItem


Declaration

procedure DrawAcquireComboListBoxItem(TheControl : TWinControl;
                                      CanvasRect : TRect;
                                      const sRawDeviceStr : string;
                                      AnImageList : TCustomImageList = nil;
                                      iScannerGlyph : Short = -1;
                                      iCameraGlyph  : Short = -1;
                                      iDriveGlyph   : Short = -1;
                                      iDeviceGlyph  : Short = -1;
                                      iUnknownGlyph : Short = -1);


Description

If you use FillListWithSources to fill a list box or combo box you can use this method to custom draw the item from the controls OnDrawItem event.

TheControl, CanvasRect are passed from the event parameters.
sRawDeviceStr will be TheControl.Items[Index].
If you have a TImageList containing glyphs then pass it as AnImageList and the index of each relevant glyph as iScannerGlyph, iCameraGlyph, iDriveGlyph and iUnknownGlyph.


See Also

 FillListWithSources


Example

// Draw with glyphs from a TImageList
procedure TMyForm.lbxSourcesDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
const
  Scanner_Glyph_Index = 0;
  Camera_Glyph_Index  = 1;
  Drive_Glyph_Index   = 2;
  Device_Glyph_Index  = 3;
  Unknown_Glyph_Index = 4; // Probably a scanner
begin
  // lbxSources Style has been set to lbOwnerDrawFixed
  DrawAcquireComboListBoxItem(Control, Rect, lbxSources.Items[Index], imlDevices,
                              Scanner_Glyph_Index, Camera_Glyph_Index, Drive_Glyph_Index, Device_Glyph_Index, Unknown_Glyph_Index);
end;

// Draw source names only (no glyphs)
procedure TMyForm.lbxSourcesDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  // lbxSources Style has been set to lbOwnerDrawFixed
  DrawAcquireComboListBoxItem(Control, Rect, lbxSources.Items[Index]);
end;