1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
-
|
|
|
|
|
-
|
|
|
!
-
|
|
|
|
|
|
|
|
|
|
!
-
-
|
|
-
|
|
|
|
|
|
|
!
!
!
| #include "user32.as"
#include "gdi32.as"
#include "v3_042_OwnerDrawListBox_smp1.as"
sdim colname, MAXSTRING+1, ITEMNUMBER
colname.0 = "Deep Pink", "Light Coral", "Dark Orange", "Golden Rod"
colname.4 = "Pale Green", "Lawn Green", "Lime Green", "Medium Sea Green"
colname.8 = "Dodger Blue", "Royal Blue", "Slate Blue", "Medium Blue"
colname.12 = "Purple", "Dark Violet", "Copper", "Plum"
dim bgcolor, ITEMNUMBER
bgcolor.0 = RGB(255,20,147), RGB(240,128,128),RGB(255,140,0),RGB(218,165,32)
bgcolor.4 = RGB(152,251,152), RGB(124,252,0),RGB(50,205,50),RGB(60,179,113)
bgcolor.8 = RGB(30,144,255), RGB(65,105,225),RGB(106,90,205),RGB(0,0,205)
bgcolor.12 = RGB(128,0,128), RGB(148,0,211),RGB(191,0,223),RGB(221,160,221)
sdim szItem, MAXSTRING+1
screen 0, dspx, dspy, 0, dspx/2-160, dspy/2-120, 320, 240
hOwner = hwnd
cxOwner = ginfo_winx
cyOwner = ginfo_winy
cxList = cxOwner-MARGIN
cyList = cyOwner-MARGIN
syscolor 15: boxf
oncmd gosub *On_Command, WM_COMMAND
oncmd gosub *On_MeasureItem, WM_MEASUREITEM
oncmd gosub *On_DrawItem, WM_DRAWITEM
pos MARGIN/2, MARGIN/2
style = WS_CHILD | WS_VISIBLE | WS_VSCROLL
style |= LBS_NOTIFY | LBS_HASSTRINGS | LBS_OWNERDRAWFIXED
winobj "LISTBOX", "", WS_EX_CLIENTEDGE, style, cxList, cyList, IDC_LISTBOX, 0
hList = objinfo(stat,2)
sendmsg hList, WM_SETREDRAW, 0, 0
repeat ITEMNUMBER
sendmsg hList, LB_ADDSTRING, cnt, colname.cnt
loop
sendmsg hList, WM_SETREDRAW, 1, 0
stop
*On_MeasureItem
dupptr _mis, lparam, 24, 4
sign = _mis.4
return 1
*On_DrawItem
dupptr _dis, lparam, 48, 4
dup itemID, _dis.2: dup itemAct, _dis.3
dup itemSta, _dis.4: dup hCtrl, _dis.5
dup itemDC, _dis.6
dup rcLeft, _dis.7: dup rcTop, _dis.8
dup rcRight, _dis.9: dup rcBottom, _dis.10
sendmsg hList, LB_GETTEXT, itemID, varptr(szItem)
if itemID\2{
CreatePen 0, 0, RGB(240, 248, 255)
hPen = stat
CreateSolidBrush RGB(240, 248 ,255)
hBrush = stat
}else{
CreatePen 0, 0, RGB(255, 240, 245): hPen = stat
CreateSolidBrush RGB(255, 240, 245): hBrush = stat
}
SelectObject itemDC, hPen: holdPen = stat
SelectObject itemDC, hBrush: holdBrush = stat
Rectangle itemDC, rcLeft, rcTop, rcRight, rcBottom
SelectObject itemDC, holdBrush
SelectObject itemDC, holdPen
DeleteObject hBrush
DeleteObject hPen
if itemSta & ODS_SELECTED{
CreatePen 0, 0, bgcolor(itemID): hPen = stat
CreateSolidBrush bgcolor(itemID): hBrush = stat
SelectObject itemDC, hPen: holdPen = stat
SelectObject itemDC, hBrush: holdBrush = stat
Ellipse itemDC, rcLeft, rcTop, rcLeft+sign, rcBottom
Ellipse itemDC, rcRight-sign, rcTop, rcRight, rcBottom
SelectObject itemDC, holdBrush
SelectObject itemDC, holdPen
DeleteObject hBrush
DeleteObject hPen
}
SetTextColor itemDC, RGB(0,0,0)
SetBkMode itemDC, TRANSPARENT
rc = rcLeft+sign+1, rcTop, rcRight-signa-1, rcBottom
DrawText itemDC, szItem, -1, varptr(rc), $00008000
return 1
*On_Command
if (wparam & $FFFF) = IDC_LISTBOX{
if (wparam>>16&$FFFF) = LBN_SELCHANGE{
sendmsg hList, LB_GETCURSEL, 0, 0
sel = stat
if sel ! -1{
sendmsg hList, LB_GETTEXT, sel, varptr(szItem)
title szItem
col = bgcolor(sel)
color col&$FF, col>>8&$FF, col>>16&$FF
boxf
}
}
}
return 0
|