$INCLUDE "RAPIDQ.INC"
DECLARE SUB ListBoxDrawItem(Index AS INTEGER, State AS BYTE, Rect AS QRECT)
DECLARE SUB ListBoxMeasureItem(Index AS INTEGER, Height AS INTEGER)
DIM Font AS QFONT
Font.Size = 16
DIM Bitmap(10) AS QBITMAP
DIM SRect AS QRECT
SRect.Top = 0
SRect.Left = 0
SRect.Right = 20
SRect.Bottom = 20
Bitmap(0).BMP = "FLOPPY.BMP"
Bitmap(0).Transparent = True
Bitmap(1).BMP = "BOOK.BMP"
Bitmap(1).Transparent = True
Bitmap(2).BMP = "COFFEE.BMP"
Bitmap(2).Transparent = True
Bitmap(3).BMP = "GAME5.BMP"
Bitmap(3).Transparent = True
Bitmap(4).BMP = "GAME5.BMP"
Bitmap(4).Transparent = True
CREATE Form AS QFORM
Center
CAPTION = "OwnerDraw ListBox"
CREATE ListBox AS QLISTBOX
Align = alClient
Font = Font
Style = lbOwnerDrawVariable
OnDrawItem = ListBoxDrawItem
OnMeasureItem = ListBoxMeasureItem
ItemHeight = Bitmap(0).Height
AddItems "Floppy Disk","Open Book","Coffee","TicTacToe"
ItemIndex = 0
END CREATE
SHOWMODAL
END CREATE
SUB ListBoxMeasureItem(Index AS INTEGER, Height AS INTEGER)
Height = Bitmap(Index).Height+2
END SUB
SUB ListBoxDrawItem(Index AS INTEGER, State AS BYTE, Rect AS QRECT)
IF State = 0 THEN
ListBox.FillRect(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, &H00FF00)
ELSE
ListBox.FillRect(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, &HFFFFFF)
END IF
ListBox.TextOut(100, Rect.Top+(Rect.Bottom-Rect.Top)/4, ListBox.Item(index), 0, -1)
ListBox.Draw(Rect.Left, Rect.Top, Bitmap(Index).BMP)
END SUB
|