Hello
The default behaviour in ListIconGadget when specifying and icon is to append it at the beginning of row (1st column)
is there a way to put the icon at any position (any column) ?
Thanks.
ListiconGadget with icon in any column
Re: ListiconGadget with icon in any column
On Windows you can do this using Windows API. I don't have the code by hand, but there's some examples here in the forum.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: ListiconGadget with icon in any column
I tried the follwing code but the problem is that it still keeps the first icon (left) or a space insteadjacdelad wrote: Mon Feb 19, 2024 8:00 pm On Windows you can do this using Windows API. I don't have the code by hand, but there's some examples here in the forum.
Code: Select all
;Autor: Kurzer
;http://www.purebasic.fr/german/viewtopic.php?p=250562#p250562
EnableExplicit
Procedure SetGadgetItemIcon(iGadgetNr.i, iRow.i, iCol.i, iIcon.i, iSet.i)
Protected lvi.lv_item
lvi\mask = #LVIF_IMAGE
lvi\iItem = iRow ; row number for change
lvi\iSubItem = iCol ; 2nd subitem
lvi\pszText = #Null ; text to change to
If iSet
lvi\iImage = iIcon ; Icon setzen
Else
lvi\iImage = -1 ; Icon löschen
EndIf
SendMessage_(GadgetID(iGadgetNr), #LVM_SETITEM, 0, @lvi)
EndProcedure
Define iGadgetNr.i, hListIconGadget.i, hImlImages.i, iStyle.i, Event.i
Define sText.s
If OpenWindow(0, 100, 100, 350, 100, "Icons in allen ListIcon-Spalten, nicht nur in der ersten.", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; ListIconGadget anlegen
iGadgetNr = ListIconGadget(#PB_Any, 5, 5, 340, 90, "Dummy", 50, #PB_ListIcon_FullRowSelect) ;#PB_ListIcon_AlwaysShowSelection|#LVS_NOCOLUMNHEADER)
; 4 weitere Spalten zufügen
AddGadgetColumn(iGadgetNr, 1, "1", 16)
AddGadgetColumn(iGadgetNr, 2, "2", 100)
AddGadgetColumn(iGadgetNr, 3, "3", 80)
AddGadgetColumn(iGadgetNr, 4, "4", 80)
; Und drei Beispiel-Zeilen erzeugen
AddGadgetItem(iGadgetNr, -1, #LF$ + "" + #LF$ + " Ernst" + #LF$ + " hungrig")
AddGadgetItem(iGadgetNr, -1, #LF$ + "" + #LF$ + " Karl" + #LF$ + " faul")
AddGadgetItem(iGadgetNr, -1, #LF$ + "" + #LF$ + " Gabi" + #LF$ + " schön")
hListIconGadget = GadgetID(iGadgetNr)
; Eine Imagelist aufbauen
CatchImage(0, ?Test)
hImlImages = ImageList_Create_(16, 16, #ILC_COLOR32 | #ILC_MASK, 0, 8) ; | #ILC_MASK
ImageList_AddMasked_(hImlImages, ImageID(0), #CLR_NONE)
; Das "PB-eigenen" Image ist jetzt nicht mehr nötig, weil es in die ImageList kopiert wurde
FreeImage(0)
; Die Imagelist dem ListIconGadget zuordnen
SendMessage_(hListIconGadget, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImlImages)
; Jetzt dem ListIconGadget sagen, daß es auch in SubItems Icons anzeigel soll/darf
iStyle = SendMessage_(hListIconGadget, #LVM_GETEXTENDEDLISTVIEWSTYLE , 0, 0) | #LVS_EX_SUBITEMIMAGES
SendMessage_(hListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE , 0, iStyle)
; SendMessage_(hListIconGadget, #LVM_SETTEXTBKCOLOR , 0, #White)
; SendMessage_(hListIconGadget, #LVM_SETBKCOLOR, 0, #White)
;Die blöden, per default gesetzen Icons in Spalte 0 entfernen
SetGadgetItemIcon(iGadgetNr, 0, 0, 0, #False)
SetGadgetItemIcon(iGadgetNr, 1, 0, 0, #False)
SetGadgetItemIcon(iGadgetNr, 2, 0, 0, #False)
;Jetzt die Icons nachträglich in die Spalten setzen
SetGadgetItemIcon(iGadgetNr, 0, 1, 2, #True)
SetGadgetItemIcon(iGadgetNr, 1, 1, 2, #True)
SetGadgetItemIcon(iGadgetNr, 2, 1, 2, #True)
SetGadgetItemIcon(iGadgetNr, 0, 2, 1, #True)
SetGadgetItemIcon(iGadgetNr, 1, 2, 1, #True)
SetGadgetItemIcon(iGadgetNr, 2, 2, 0, #True)
SetGadgetItemIcon(iGadgetNr, 0, 4, 2, #True)
SetGadgetItemIcon(iGadgetNr, 1, 4, 2, #True)
SetGadgetItemIcon(iGadgetNr, 2, 4, 2, #True)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
; Am Ende die Imagelist wieder freigeben
ImageList_Destroy_(hImlImages)
EndIf
DataSection
; Dies ist ein 16 Farben BMP Image mit 48 x 16 Pixeln Ausmaße (also quasi drei 16 x 16 Pixel große Images nebeneinander)
Test:
; IncludeBinary "test.bmp"
Data.l $01F64D42,$00000000,$00760000,$00280000,$00300000,$00100000,$00010000,$00000004,$01800000,$00000000
Data.l $00000000,$00000000,$00000000,$02040000,$FEFC00FC,$02FC00FC,$00000004,$FC820000,$3A00002D,$3C0000FF
Data.l $00000091,$5500007C,$01000001,$02000000,$00000000,$E9910000,$43B10061,$003700AC,$007E0080,$1111007C
Data.l $11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111
Data.l $11111111,$11111111,$11111111,$10111111,$10111101,$11111101,$11111111,$11111111,$11222211,$11111111
Data.l $00111100,$11111111,$11111111,$11111111,$21222212,$11111111,$01000010,$11111111,$11111111,$11111111
Data.l $22111122,$11111111,$11000011,$11111111,$11881811,$12111111,$12111121,$11111121,$11111111,$11111111
Data.l $81888811,$11111111,$11211211,$11111111,$11011011,$11111111,$88888818,$11111111,$11211211,$11111111
Data.l $11011011,$11111111,$88888818,$11111111,$11211211,$11111111,$11011011,$11111111,$88888818,$12111111
Data.l $12111121,$10111121,$10111101,$11111101,$81888811,$22111111,$22111122,$00111122,$00111100,$11111100
Data.l $11881811,$22111111,$22111122,$00111122,$00111100,$11111100,$11111111,$12111111,$12111121,$10111121
Data.l $10111101,$11111101,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111,$11111111
Data.l $11111111,$11111111,$11111111,$11111111,$11111111
Data.b $11,$11
EndDataSection
Re: ListiconGadget with icon in any column
It's not possible to put icons in other columns and NOT in the first one. The first one ALWAYS has an icon (or a blank space, if no icon is set).
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: ListiconGadget with icon in any column
so basically this is IMPOSSIBLE ?? 

Re: ListiconGadget with icon in any column
I thought I clearly stated this.
Seriously, it's a Microsoft thing, not that I'm aware of something we can do about it. You can maybe circumvent this by ownerdrawing...not my métier.

Seriously, it's a Microsoft thing, not that I'm aware of something we can do about it. You can maybe circumvent this by ownerdrawing...not my métier.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: ListiconGadget with icon in any column
It will be difficult for a beginner to understand this, especially since I tried several drawing methods here.
Here is the author of an example of drawing menu items
https://www.purebasic.fr/english/viewto ... ES#p235655
here I made a simplified example for myself
https://pastebin.com/3Dm5XpGi
Now I made an example with drawing an icon next to the item
Here is the author of an example of drawing menu items
https://www.purebasic.fr/english/viewto ... ES#p235655
here I made a simplified example for myself
https://pastebin.com/3Dm5XpGi
Now I made an example with drawing an icon next to the item
Code: Select all
Global hIcon = 0
Global hIcon2 = 0
ExtractIconEx_("Shell32.dll", 131, 0, @hIcon, 1)
ExtractIconEx_("Shell32.dll", 3, 0, @hIcon2, 1)
; ExtractIconEx_("C:\ProgramData\PureBasic\Examples\Sources\Data\CdPlayer.ico", 0, 0, @hIcon, 1)
; Debug hIcon
Global g_tRect.RECT
With g_tRect
\left = 0
\top = 0
\right = 16
\bottom = 16
EndWith
Global hDC, MemDC
Global hOldBMP
Procedure CreateBMP()
Protected hBrush, MemBMP, Rect.RECT
MemBMP = CreateCompatibleBitmap_(hDC, 16, 16)
hOldBMP = SelectObject_(MemDC, MemBMP)
hBrush = CreateSolidBrush_($0088FF)
SelectObject_(MemDC, hBrush)
With Rect
\left = 0
\right = 16
\top = 0
\bottom = 16
EndWith
FillRect_(MemDC, Rect, hBrush)
DeleteObject_(hBrush)
DeleteObject_(MemBMP)
EndProcedure
Procedure LB_CreateSolidBitmap(hWnd, iColor, iWidth, iHeight, bRGB = 1)
; Protected Error_FillRect = 0
Protected hBrush
Protected hDC = GetDC_(hWnd)
Protected hDestDC = CreateCompatibleDC_(hDC)
Protected hBitmap = CreateCompatibleBitmap_(hDC, iWidth, iHeight)
Protected hOld = SelectObject_(hDestDC, hBitmap)
Protected tRect.RECT
With tRect
\left = 0
\top = 0
\right = iWidth
\bottom = iHeight
EndWith
If bRGB
iColor = ((iColor & $00FF00) | ((iColor & $0000FF) << 16) | ((iColor & $FF0000) >> 16))
EndIf
hBrush = CreateSolidBrush_(iColor)
FillRect_(hDestDC, tRect, hBrush)
; If Error_FillRect
; DeleteObject_(hBitmap)
; hBitmap = 0
; EndIf
DeleteObject_(hBrush)
ReleaseDC_(hWnd, hDC)
SelectObject_(hDestDC, hOld)
DeleteDC_(hDestDC)
If Not hBitmap
ProcedureReturn 0
EndIf
ProcedureReturn hBitmap
EndProcedure
#LV0 = 0
Global BackColor = $00FF00
Global ForeColor = $FF0000
Global BackColorHeader = $eeffee
Global ForeColorHeader = $2277ff
Global BorderColor = $0
Global HightLightBrush = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
; Global HightLightBrush = CreateSolidBrush_($ff3926)
Global BackColorBrush = CreateSolidBrush_(BackColor)
Global BackColorBrushHeader = CreateSolidBrush_(BackColorHeader)
Global frmMain_References, hHeader
Global Dim Colors(1)
Colors(0) = $8080FF
Colors(1) = ForeColor
; ---------------------------------------------------------------------------------------------------------------------
Procedure GetCharWidth(gad, c$)
ProcedureReturn SendMessage_(gad, #LVM_GETSTRINGWIDTH, 0, @c$)
EndProcedure
; это подкрашивает части пункта в ListView
Procedure Callback_Win(hwnd, msg, wParam, lParam)
Protected Result, *nmhdr.NMHDR, *lvCD.NMLVCUSTOMDRAW, subItemRect.RECT, *DrawItem.DRAWITEMSTRUCT, Buffer.s
Protected *pnmcd.NMCUSTOMDRAW, hdi.hd_item
Protected thisRow, thisCol, idx
Protected t$, text$
Protected nNotifyCode
Protected *NMITEM.NMITEMACTIVATE
Protected SelectedLine
Result = #PB_ProcessPureBasicEvents
;;Dim LVColor(0)
Select msg
Case #WM_NCDESTROY ; удаление кистей, после закрытия программы
DeleteObject_(HightLightBrush)
DeleteObject_(BackColorBrush)
DeleteObject_(BackColorBrushHeader)
Case #WM_NOTIFY
; стандартные структуры ListView для перерисовки
*nmhdr.NMHDR = lParam
*lvCD.NMLVCUSTOMDRAW = lParam
*NMITEM.NMITEMACTIVATE = lParam
; если гаджет #LV0 и он пользовательская рисовка, то
If *lvCD\nmcd\hdr\hwndFrom = GadgetID(#LV0) And *lvCD\nmcd\hdr\code = #NM_CUSTOMDRAW
Select *lvCD\nmcd\dwDrawStage
Case #CDDS_PREPAINT
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
Result = #CDRF_NOTIFYSUBITEMDRAW;
Case #CDDS_ITEMPREPAINT | #CDDS_SUBITEM ; перерисовка пункта
thisRow = *lvCD\nmcd\dwItemSpec ; строку
thisCol = *lvCD\iSubItem ; колонка
If thisCol = 1 Or thisCol = 3 ; если колонка 0, то
; Определяет прямоугольник для текста
subItemRect.RECT\left = #LVIR_BOUNDS ; #LVIR_ICON, #LVIR_LABEL
subItemRect.RECT\top = *lvCD\iSubItem ; iSubItem
; Определяет прямоугольник подпункт
SendMessage_(GadgetID(#LV0), #LVM_GETSUBITEMRECT, thisRow, @subItemRect) ; в итоге переписываем структуру прямоугольника
; subItemRect.RECT\left = #LVIR_ICON
; SendMessage_(GadgetID(#LV0), #LVM_GETSUBITEMRECT, thisRow, @subItemRect) ; в итоге переписываем структуру прямоугольника
; subItemRect.RECT\left + 160
text$ = GetGadgetItemText(#LV0, thisRow, thisCol) ; получаем текст пункта по строке и колонке
If GetGadgetState(#LV0) = thisRow ; если индекс выделенного элемента равен пункту, то
; выделенный пункт, перекрашиваем его фон
FillRect_(*lvCD\nmcd\hdc, subItemRect, HightLightBrush)
SetTextColor_(*lvCD\nmcd\hdc, $00FFFF) ;
Else
; не выделенный пункт, перекрашиваем его другим фоном
FillRect_(*lvCD\nmcd\hdc, subItemRect, BackColorBrushHeader)
SetTextColor_(*lvCD\nmcd\hdc, ForeColor) ;
EndIf
CopyStructure(@subItemRect, @g_tRect, RECT)
; Debug subItemRect\left
; Debug subItemRect\right
; Debug subItemRect\top
; Debug subItemRect\bottom
; With g_tRect
; \bottom = \top + 16
; EndWith
InflateRect_(subItemRect, -16, 0) ; изменяет левую границу прямоугольника на 8 пиксел
; SetBkColor_(*lvCD\nmcd\hdc, BackColor) ; фон всегда одинаковый, он вообще не нужен
DrawText_(*lvCD\nmcd\hdc, text$, -1, subItemRect, #DT_END_ELLIPSIS | #DT_VCENTER | #DT_SINGLELINE) ; рисуем текст
; DrawIcon_(*lvCD\nmcd\hdc, g_tRect\left, g_tRect\top, hIcon)
;LB_CreateSolidBitmap(hWnd, iColor, iWidth, iHeight, bRGB = 1)
With g_tRect
\left + 0
\right = \left + 12
\top + 6
\bottom = \top + 12
EndWith
; DrawEdge_(*lvCD\nmcd\hdc, @g_tRect, #EDGE_SUNKEN, #BF_RECT)
; FillRect_(*lvCD\nmcd\hdc, g_tRect, BackColorBrush)
; DrawIcon_(*lvCD\nmcd\hdc, subItemRect\left, subItemRect\top, hIcon)
If thisRow % 2
DrawIconEx_(*lvCD\nmcd\hdc, g_tRect\left, g_tRect\top, hIcon, 16, 16, 0, 0, #DI_NORMAL)
Else
DrawIconEx_(*lvCD\nmcd\hdc, g_tRect\left, g_tRect\top, hIcon2, 16, 16, 0, 0, #DI_NORMAL)
EndIf
; With g_tRect
; BitBlt_(*lvCD\nmcd\hdc, \left, \top, \right - \left, \bottom - \top, MemDC, 0, 0, #SRCCOPY)
; EndWith
Result = #CDRF_SKIPDEFAULT
Else
Result = #CDRF_DODEFAULT
EndIf
EndSelect
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
; это подкрашивает заголовок ListView
Procedure Callback_Header(hWnd, Message, wParam, lParam)
Protected *Header.HD_NOTIFY, SelectedLine, *lvCD.NMLVCUSTOMDRAW
Protected *nmhdr.NMHDR, text$, *pnmcd.NMCUSTOMDRAW, hdi.hd_item
Protected rc2.RECT, hDC
Protected Result = CallWindowProc_(frmMain_References, hWnd, Message, wParam, lParam)
*Header = lParam
*nmhdr = lParam
*lvCD = lParam
Select Message
Case #WM_NOTIFY
Select *Header\hdr\code
Case #NM_CUSTOMDRAW
If *nmhdr\hwndFrom = hHeader
*pnmcd.NMCUSTOMDRAW = lParam
Select *pnmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
text$ = GetGadgetItemText(GetDlgCtrlID_(hWnd), -1, *pnmcd\dwItemSpec)
hdi\mask = #HDI_TEXT
hdi\psztext = @text$
hdi\cchtextmax = Len(text$)
SetBkMode_(*pnmcd\hdc, #TRANSPARENT)
FillRect_(*pnmcd\hdc, *pnmcd\rc, BackColorBrushHeader)
; сдвигаем текст после закрашивания прямоуголников
If *lvCD\nmcd\dwItemSpec
InflateRect_(*pnmcd\rc, -8, 0)
; text$ = LTrimChar(text$, " " + #TAB$)
Else
InflateRect_(*pnmcd\rc, -4, 0)
EndIf
SetTextColor_(*pnmcd\hdc, ForeColorHeader)
DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_VCENTER | #DT_END_ELLIPSIS)
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
;- ╔═ GUI ═╗
If OpenWindow(0, 0, 0, 420, 400, "Пример...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; for BitBlt
hDC = GetDC_(WindowID(0))
MemDC = CreateCompatibleDC_(hDC)
CreateBMP()
ListIconGadget(#LV0, 10, 10, 400, 380, "Col0", 70, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
; SetGadgetAttribute(#LV0 , #PB_ListIcon_DisplayMode , #PB_ListIcon_Report)
AddGadgetColumn(#LV0, 1, "Col1", 70)
AddGadgetColumn(#LV0, 2, "Col2", 70)
AddGadgetColumn(#LV0, 3, "Col3", 80)
AddGadgetColumn(#LV0, 4, "Col4", 80)
For a = 0 To 4
AddGadgetItem(#LV0, a, "item" + #LF$ + "item" + #LF$ + "item" + #LF$ + "item")
Next
; SetGadgetColor(#LV0, #PB_Gadget_BackColor, BackColorHeader)
; ListViewGadget(0, 10, 10, 400, 380)
; For a = 1 To 12
; AddGadgetItem(0, -1, "Элемент " + Str(a) + " Списка") ; Определить содержимое списка.
; Next
SetWindowCallback(@Callback_Win())
; hHeader = SendMessage_(GadgetID(#LV0), #LVM_GETHEADER, 0, 0)
; frmMain_References = SetWindowLongPtr_(GadgetID(#LV0), #GWL_WNDPROC, @Callback_Header())
; SetBkColor_(hHeader, BackColor)
;- Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
; for ExtractIconEx
DestroyIcon_(hIcon)
DestroyIcon_(hIcon2)
; for BitBlt
ReleaseDC_(WindowID(0), hDC)
SelectObject_(MemDC, hOldBMP)
DeleteDC_(MemDC)
CloseWindow(0)
End
EndSelect
ForEver
EndIf
Re: ListiconGadget with icon in any column
This code comes from RASHAD, you can put images in any cell.
HTH
HTH
Code: Select all
Global HitInfo.LVHITTESTINFO , ii.lv_item
ii\mask = #LVIF_IMAGE
Procedure SetItemState(Row,Col,Img)
ii\iItem = Row
ii\iSubItem = Col
ii\iImage = Img
SendMessage_(GadgetID(0), #LVM_SETITEM, 0, @ii)
EndProcedure
Procedure GetItemState(Row,Col)
ii\iItem = Row
ii\iSubItem = Col
ii\iImage = Img
SendMessage_(GadgetID(0), #LVM_GETITEM, 0, @ii)
ProcedureReturn ii\iImage
EndProcedure
LoadFont(0,"Consolas",20);,#PB_Font_Bold )
imgs = 24
CreateImage(0,imgs,imgs,32,#PB_Image_Transparent)
hdc = StartDrawing(ImageOutput(0))
Box(0,0,imgs,imgs,$B4B4B4)
Box(2,2,imgs-4,imgs-4,$EFEFEF)
StopDrawing()
CreateImage(1,imgs,imgs,32,#PB_Image_Transparent)
hdc = StartDrawing(ImageOutput(1))
Box(0,0,imgs,imgs,$B4B4B4)
Box(2,2,imgs-4,imgs-4,$EFEFEF)
Box(5,5,imgs-10,imgs-10,$0000FF)
StopDrawing()
il = ImageList_Create_(imgs,imgs,#ILC_COLOR32| #ILC_MASK, 0, 2)
ImageList_Add_(il,ImageID(0),0)
ImageList_Add_(il,ImageID(1),0)
FreeImage(0)
FreeImage(1)
OpenWindow(0,0,0,400,310, "", #PB_Window_ScreenCentered |#PB_Window_SystemMenu )
ListIconGadget(0,10,10,380,250,"",0, #PB_ListIcon_CheckBoxes | #LVS_NOCOLUMNHEADER )
SendMessage_(GadgetID(0), #LVM_SETEXTENDEDLISTVIEWSTYLE , #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES)
ButtonGadget(1,10,280,60,20,"Get State")
SetGadgetColor(0,#PB_Gadget_BackColor,$D1F1FF)
SetGadgetFont(0,FontID(0))
AddGadgetColumn(0, 1, "",180)
AddGadgetColumn(0, 2, "",imgs+8)
AddGadgetColumn(0, 3, "",imgs+8)
AddGadgetColumn(0, 4, "",imgs+8)
AddGadgetItem(0, -1, Chr(10)+"Alpha"+Chr(10)+Chr(10)+Chr(10))
AddGadgetItem(0, -1, Chr(10)+"Beta"+Chr(10)+Chr(10)+Chr(10))
AddGadgetItem(0, -1, Chr(10)+"Gamma"+Chr(10)+Chr(10)+Chr(10))
AddGadgetItem(0, -1, Chr(10)+"Delta"+Chr(10)+Chr(10)+Chr(10))
SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, il)
itemn = SendMessage_(GadgetID(0), #LVM_GETITEMCOUNT, 0,0)
Dim order(subn)
For sub = 0 To subn
order(sub)=sub+1
Next
SendMessage_(GadgetID(0), #LVM_SETCOLUMNORDERARRAY, subn, @order())
For cel = 0 To itemn
setItemState(cel,2,0)
setItemState(cel,3,0)
setItemState(cel,4,0)
Next
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftClick
Hitinfo\pt\x = WindowMouseX(0)-8 ; 32 -24 = 8
HitInfo\pt\y = WindowMouseY(0)-8
SendMessage_(GadgetID(0),#LVM_SUBITEMHITTEST,0,@HitInfo)
GetItemState(hitinfo\iitem,hitinfo\iSubItem)
index = ii\iImage
SetItemState(hitinfo\iitem,hitinfo\iSubItem,index ! 1)
EndSelect
Case 1
Debug GetItemState(1,2)
EndSelect
EndSelect
Until Quit = 1
End
PureBasic: Surprisingly simple, diabolically powerful