Tested under Win2000 only:
Code:
#Compile Exe #Dim All #Register None #Include "WIN32API.INC" %ID_LIST1 = 130 %nEl = 1000 Global arr() As String CallBack Function DlgProc Select Case CbMsg Case %WM_DRAWITEM Local lpdis As DRAWITEMSTRUCT Ptr lpdis = CbLparam If @lpdis.itemID = -1 Then Exit Function If IsFalse(@lpdis.itemState And %ODS_SELECTED) Then FillRect @lpdis.hDC, @lpdis.rcItem, GetStockObject(%WHITE_BRUSH) SetBkColor @lpdis.hDC, %WHITE SetTextColor @lpdis.hDC, %BLACK Else FillRect @lpdis.hDC, @lpdis.rcItem, GetStockObject(%BLACK_BRUSH) SetBkColor @lpdis.hDC, %BLACK SetTextColor @lpdis.hDC, %WHITE End If TextOut @lpdis.hDC, 0, @lpdis.rcItem.ntop, ByVal StrPtr(arr(@lpdis.itemID)), Len(arr(@lpdis.itemID)) Function = 1: Exit Function End Select End Function Function PbMain Local hDlg As Long, i As Long, hList As Long Dialog New 0, "Listbox", , , 100, 70, %WS_CAPTION Or %WS_SYSMENU To hDlg Control Add ListBox, hDlg, %ID_LIST1, , 5, 5, 90, 65, _ %WS_CHILD Or %LBS_OWNERDRAWFIXED Or _ %WS_TABSTOP Or %LBS_DISABLENOSCROLL Or %WS_VSCROLL, %WS_EX_CLIENTEDGE Control Handle hDlg, %ID_LIST1 To hList ReDim arr(%nEl - 1) For i = 0 To %nEl - 1 arr(i) = "Item" + Str$(i) SendMessage hList, %LB_ADDSTRING, i, 0 Next SendMessage hList, %LB_SETCURSEL, 3, 0 ' Item 3 Dialog Show Modal hDlg, Call DlgProc End Function
E-MAIL: [email protected]
Leave a comment: