Guidance
指路人
g.yi.org
software / rapidq / examples / gui / listbox & ComboBox / owndraw / listbox.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' OwnerDraw ListBox, this can also be extended to comboboxes

     $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               '-- Variable height
       OnDrawItem = ListBoxDrawItem
       OnMeasureItem = ListBoxMeasureItem        '-- Note, order IS important!
       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)
  ' This subrountine is needed ONLY if your list box is lbOwnerDrawVariable
      Height = Bitmap(Index).Height+2
     END SUB


     SUB ListBoxDrawItem(Index AS INTEGER, State AS BYTE, Rect AS QRECT)
      IF State = 0 THEN
    '-- Selected
       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
掌柜推荐
 
 
¥738.00 ·
 
 
¥890.00 ·
 
 
¥1,280.00 ·
 
 
¥264.00 ·
 
 
¥317.00 ·
 
 
¥296.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2000-01-11 13:57:16