Code: Select all
; English forum: http://www.purebasic.fr/english/viewtopic.php?t=6203&highlight=
; Author: Freak (updated for PB4.00 by blbltheworm)
; Date: 21. May 2003
; OS: Windows
; Demo: Yes
Global a,b
#ListIcon = 1
LoadFont(0, "tahoma", 12)
Procedure Callback(Window.l, Message.l, wParam.l, lParam.l)
result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_NOTIFY ; these events are send as notification messages
*pnmh.NMHDR = lParam ; lParam points to a structure with more info
If *pnmh\hwndFrom = GadgetID(#ListIcon) ; see if it is the right gadget
Select *pnmh\code ; code contains actual message
; Case #LVN_COLUMNCLICK ; user clicked on the Header of a column
; *pnmv.NMLISTVIEW = lParam ; another info structure
; Column.l = *pnmv\iSubItem ; clicked column
;MessageRequester("Column Header Click","Clicked on Column "+Str(Column),0)
Case #NM_CLICK ; user clicked in the ListView
*lpnmitem.NMITEMACTIVATE = lParam
Row.l = *lpnmitem\iItem
Column.l = *lpnmitem\iSubItem
Result$ = GetGadgetItemText(#ListIcon, row, Column)
SetGadgetText(2,result$)
;Debug "Row: "+ Str(Row+1)+ " Column: "+ Str(Column+1) + " " + result$
a=row:b=column
; there is also
; #NM_DBLCLK - doublecklick
; #NM_RCLICK - right button
; #NM_RDBLCLK - right doubleclick
; they work the same as #NM_CLICK
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,400,400, "Listicon test...",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
StringGadget(2,150,350,120,25,"")
SetGadgetFont(2, FontID(0))
ButtonGadget(3,300,340,40,40,"OK")
ListIconGadget(#ListIcon, 10, 10, 380, 300, "Column1", 140,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
SetGadgetFont(#ListIcon, FontID(0))
; Fullrowselect must be set, because otherwiese only the first
; column will be clickable
AddGadgetColumn(#ListIcon, 1, "Column2", 140)
AddGadgetColumn(#ListIcon, 2, "Column3", 140)
AddGadgetItem(#ListIcon, 0, "Richard"+Chr(10)+"Peeters"+Chr(10)+"man")
AddGadgetItem(#ListIcon, 1, "Mie"+Chr(10)+"Kockaerts"+Chr(10)+"vrouw")
AddGadgetItem(#ListIcon, 2, "Laurens"+Chr(10)+"Lemahieu"+Chr(10)+"jongen")
AddGadgetItem(#ListIcon, 3, "Klaartje"+Chr(10)+"Lasso"+Chr(10)+"meisje")
SetWindowCallback(@Callback())
Repeat
EventID.l=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 3
x$= GetGadgetText(2)
SetGadgetItemText(#ListIcon,a,x$,b)
EndSelect
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
Sometimes one must click several times to get a reaction. Why?
Richard