Select cell in a ListIconGadget
Select cell in a ListIconGadget
Hello,
I have filled a ListIconGadget with data from a database. Now I want to select a random cell by mouseclick. By 'GetGadgetItemText()' I want to get the content of that cell. But where can I get from the record and column parameters for that command?
Background is, that I want to write the content of the selected cell in a StringGadget, edit it there and write it back to the database.
Any help is appreciated.
I have filled a ListIconGadget with data from a database. Now I want to select a random cell by mouseclick. By 'GetGadgetItemText()' I want to get the content of that cell. But where can I get from the record and column parameters for that command?
Background is, that I want to write the content of the selected cell in a StringGadget, edit it there and write it back to the database.
Any help is appreciated.
Why not use a grid gadget?
There are a few scattered around, for which my offering egrid 3 (based upon a list icon) is to be found in the announcements section.
If you do try egrid 3, please bear in mind that a massively upgraded and refined version is imminent!
If this is not appropriate, then you need to consider the #LVM_SUBITEMHITTEST message to get the information you require.
Regards.
There are a few scattered around, for which my offering egrid 3 (based upon a list icon) is to be found in the announcements section.
If you do try egrid 3, please bear in mind that a massively upgraded and refined version is imminent!

If this is not appropriate, then you need to consider the #LVM_SUBITEMHITTEST message to get the information you require.
Regards.
I may look like a mule, but I'm not a complete ass.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
If you don't mind using a userlib, you can try PureLVSORT ( http://www.purebasic.fr/english/viewtop ... 24&start=0 ) ; it has these two functions : PureLVSORT_GetClickedCellColumn() and PureLVSORT_GetClickedCellRow().
Example :
Example :
Code: Select all
OpenWindow(0, 100, 300, 420, 170, "PureLVSORT test : get clicked cells coordinates", #PB_Window_SystemMenu)
If CreateGadgetList(WindowID(0))
ListIconGadget(1, 1, 1, 250, 160, "0", 50, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(1, 1, "1", 50)
AddGadgetColumn(1, 2, "2", 50)
AddGadgetColumn(1, 3, "3", 50)
AddGadgetColumn(1, 4, "4", 50)
AddGadgetColumn(1, 5, "5", 50)
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
AddGadgetItem(1, -1, " ")
ListIconGadget(2, 260, 1, 150, 160, "0", 50, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(2, 1, "1", 50)
AddGadgetColumn(2, 2, "2", 50)
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
AddGadgetItem(2, -1, " ")
EndIf
PureLVSORT_SelectGadgetToSort(1, #PureLVSORT_ShowClickedHeader_No) ; just to register the gadget's parent window
Repeat
EventID.l = WaitWindowEvent()
GadgetID.l = EventGadget()
EventType.l = EventType()
If EventID = #PB_Event_Gadget
If GadgetID = 1
Debug "* ListIconGadget 1 Event"
If EventType = #PB_EventType_LeftClick
Debug " Left Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_LeftDoubleClick
Debug " Left DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_RightClick
Debug " Right Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_RightDoubleClick
Debug " Right DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
EndIf
EndIf
If GadgetID = 2
Debug "* ListIconGadget 2 Event"
If EventType = #PB_EventType_LeftClick
Debug "Left Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_LeftDoubleClick
Debug " Left DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_RightClick
Debug " Right Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
ElseIf EventType = #PB_EventType_RightDoubleClick
Debug " Right DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
EndIf
EndIf
ElseIf EventID = #PB_Event_CloseWindow
Break
EndIf
ForEver
;
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Ah, the hard way. A man after my own heart! But I'm sure once you've played around some you'll choose srod's egrid. It's really quite good. For the hard way, here's a bit of fun to point you in the general direction:
It's pretty easy from here to open a string gadget, take the new value, and replace the ListIcon gadgetitem text with it if you want to do that. Just use SetGadgetItemText on the same parameters. And you'll want to uncolor the box when it's not the active one anymore. I was too lazy to do that.
Code: Select all
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
Global oldlist,lv
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If msg = #WM_LBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = WindowMouseX(0)
HitInfo\pt\y = WindowMouseY(0)
SendMessage_(lv,#LVM_SUBITEMHITTEST,0,@HitInfo)
SetGadgetItemColor(0,hitinfo\iitem,#PB_Gadget_BackColor,RGB(181, 225, 241),hitinfo\iSubItem)
Debug GetGadgetItemText(0,hitinfo\iitem,hitinfo\iSubItem)
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"ListIcon Gadget Mischief: Get Selected Item",$CF0001)
CreateGadgetList(WindowID(0))
lv = ListIconGadget(0,0,0,640,480,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",210)
AddGadgetColumn(0,3,"Column 3",215)
For i = 1 To 32
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
oldlist=SetWindowLong_(lv, #GWL_WNDPROC, @SubClass_LV())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
BERESHEIT
Thanks, netmaestro, that would be exactly what I was looking for, when... yes when it would be more accurate. I explain what I mean: there is never highlighted the cell I am clicking on, but one or two cells below, depending on where I click within the cell. So I have substracted 1 from hitinfo\iitem, and when I click in the upper half of a cell, this cell is highlighted and the text is displayed. But when I come near to lower limit, the cell below is it. Very strange behaviour :roll: .
But principally it is the solution.
But principally it is the solution.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
A bit more:
For what you're doing, you may want to leave the edited cells colored until they get written to the database, to let the user know that they haven't been committed yet. Just as a possible idea.
Actually, I might find this useful myself someday. I'm going to stick it in my sourcecode folder. Thanks for tempting me to write it!
Code: Select all
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
Global oldlist,lv
Procedure.s GetNewText(item,subitem)
Select subitem
Case 1
x=WindowX(0)+GadgetX(0)+5
Case 2
x=WindowX(0)+GadgetX(0)+215
Case 3
x=WindowX(0)+GadgetX(0)+425
EndSelect
OpenWindow(1, x,DesktopMouseY()+10,260,20,"",#PB_Window_BorderLess)
GetWindowRect_(WindowID(1), editrect.rect)
ClipCursor_(editrect)
CreateGadgetList(WindowID(1))
StringGadget(1,0,0,190,20,"")
ButtonGadget(2,190,0,30,20,"OK")
ButtonGadget(3,220,0,40,20,"Cancel")
SetActiveGadget(1)
AddKeyboardShortcut(1,#PB_Shortcut_Return,1)
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,RGB(200,200,200),subitem)
quit=0
Repeat
ev=WaitWindowEvent()
If EventWindow()=1
Select ev
Case #PB_Event_Menu
If EventMenu()=1
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
EndIf
Case #PB_Event_Gadget
If EventGadget()=2
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
ElseIf EventGadget() = 3
CloseWindow(1)
quit = 1
EndIf
EndSelect
EndIf
Until quit
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,#White,subitem)
ClipCursor_(0)
EndProcedure
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If msg = #WM_RBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = WindowMouseX(0)
HitInfo\pt\y = WindowMouseY(0)
SendMessage_(lv,#LVM_SUBITEMHITTEST,0,@HitInfo)
GetNewText(hitinfo\iitem,hitinfo\iSubItem)
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"ListIcon Gadget Mischief: Edit Selected Item",$CF0001)
CreateGadgetList(WindowID(0))
lv = ListIconGadget(0,0,0,640,480,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",210)
AddGadgetColumn(0,3,"Column 3",215)
For i = 1 To 32
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
oldlist=SetWindowLong_(lv, #GWL_WNDPROC, @SubClass_LV())
Repeat
ev = WaitWindowEvent()
Until ev=#WM_CLOSE
Actually, I might find this useful myself someday. I'm going to stick it in my sourcecode folder. Thanks for tempting me to write it!
BERESHEIT
I have found something, which fulfills my needs perfectly. I have reduced it to what I need and this is the result:
Thanks for all replies.
Code: Select all
Procedure Callback(Window.l, Message.l, wParam.l, lParam.l)
lRes = #PB_ProcessPureBasicEvents
If Message = #WM_NOTIFY ; these events are send as notification messages
Define *pnmh.NMHDR = lParam ; lParam points to a structure with more info
If *pnmh\hwndFrom = GadgetID(#ListIcon_Log) ; see if it is the right gadget
If *pnmh\code = #NM_CLICK ; user clicked in the ListView
Define *lpnmitem.NMITEMACTIVATE = lParam
lRow = *lpnmitem\iItem
lCol = *lpnmitem\iSubItem
EndIf
EndIf
EndIf
ProcedureReturn lRes
EndProcedure
SetWindowCallback(@Callback())
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Hello
I have modified the great code of NETMAESTRO, because i want to put the ListIconGadget in the middle of the form.
But if i do that, the code don't works
The variable "hitinfo\iitem" in line 60 is already at -1
Somebody know why ?????
Thanks for your help
Good day
I have modified the great code of NETMAESTRO, because i want to put the ListIconGadget in the middle of the form.
But if i do that, the code don't works

The variable "hitinfo\iitem" in line 60 is already at -1

Somebody know why ?????
Code: Select all
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
Global oldlist,lv
Procedure.s GetNewText(item,subitem)
Select subitem
Case 1
x=WindowX(0)+GadgetX(0)+5
Case 2
x=WindowX(0)+GadgetX(0)+215
Case 3
x=WindowX(0)+GadgetX(0)+425
EndSelect
OpenWindow(1, x,DesktopMouseY()+10,260,20,"",#PB_Window_BorderLess)
GetWindowRect_(WindowID(1), editrect.rect)
ClipCursor_(editrect)
CreateGadgetList(WindowID(1))
StringGadget(1,0,0,190,20,"")
ButtonGadget(2,190,0,30,20,"OK")
ButtonGadget(3,220,0,40,20,"Cancel")
SetActiveGadget(1)
AddKeyboardShortcut(1,#PB_Shortcut_Return,1)
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,RGB(200,200,200),subitem)
quit=0
Repeat
ev=WaitWindowEvent()
If EventWindow()=1
Select ev
Case #PB_Event_Menu
If EventMenu()=1
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
EndIf
Case #PB_Event_Gadget
If EventGadget()=2
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
ElseIf EventGadget() = 3
CloseWindow(1)
quit = 1
EndIf
EndSelect
EndIf
Until quit
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,#White,subitem)
ClipCursor_(0)
EndProcedure
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If msg = #WM_RBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = WindowMouseX(0)
HitInfo\pt\y = WindowMouseY(0)
SendMessage_(lv,#LVM_SUBITEMHITTEST,0,@HitInfo)
GetNewText(hitinfo\iitem,hitinfo\iSubItem)
Debug hitinfo\iitem
Debug hitinfo\iSubItem
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"ListIcon Gadget Mischief: Edit Selected Item",$CF0001)
CreateGadgetList(WindowID(0))
lv = ListIconGadget(0,0,200,640,180,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",210)
AddGadgetColumn(0,3,"Column 3",215)
For i = 1 To 12
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
oldlist=SetWindowLong_(lv, #GWL_WNDPROC, @SubClass_LV())
Repeat
ev = WaitWindowEvent()
Until ev=#WM_CLOSE
Good day

Not a destination
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Hello
I have modified the great code of NETMAESTRO, because i want to put the ListIconGadget in the middle of the form.
But if i do that, the code don't works
The variable "hitinfo\iitem" in line 60 is already at -1
Somebody know why ?????
Thanks for your help
Good day
I have modified the great code of NETMAESTRO, because i want to put the ListIconGadget in the middle of the form.
But if i do that, the code don't works

The variable "hitinfo\iitem" in line 60 is already at -1

Somebody know why ?????
Code: Select all
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
Global oldlist,lv
Procedure.s GetNewText(item,subitem)
Select subitem
Case 1
x=WindowX(0)+GadgetX(0)+5
Case 2
x=WindowX(0)+GadgetX(0)+215
Case 3
x=WindowX(0)+GadgetX(0)+425
EndSelect
OpenWindow(1, x,DesktopMouseY()+10,260,20,"",#PB_Window_BorderLess)
GetWindowRect_(WindowID(1), editrect.rect)
ClipCursor_(editrect)
CreateGadgetList(WindowID(1))
StringGadget(1,0,0,190,20,"")
ButtonGadget(2,190,0,30,20,"OK")
ButtonGadget(3,220,0,40,20,"Cancel")
SetActiveGadget(1)
AddKeyboardShortcut(1,#PB_Shortcut_Return,1)
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,RGB(200,200,200),subitem)
quit=0
Repeat
ev=WaitWindowEvent()
If EventWindow()=1
Select ev
Case #PB_Event_Menu
If EventMenu()=1
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
EndIf
Case #PB_Event_Gadget
If EventGadget()=2
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
ElseIf EventGadget() = 3
CloseWindow(1)
quit = 1
EndIf
EndSelect
EndIf
Until quit
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,#White,subitem)
ClipCursor_(0)
EndProcedure
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If msg = #WM_RBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = WindowMouseX(0)
HitInfo\pt\y = WindowMouseY(0)
SendMessage_(lv,#LVM_SUBITEMHITTEST,0,@HitInfo)
GetNewText(hitinfo\iitem,hitinfo\iSubItem)
Debug hitinfo\iitem
Debug hitinfo\iSubItem
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"ListIcon Gadget Mischief: Edit Selected Item",$CF0001) ; Line modified (Height of form)
CreateGadgetList(WindowID(0))
lv = ListIconGadget(0,0,200,640,180,"",0,#PB_ListIcon_GridLines) ; Line modified (Y Pos)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",210)
AddGadgetColumn(0,3,"Column 3",215)
For i = 1 To 12 ; Line modified (Number of loop)
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
oldlist=SetWindowLong_(lv, #GWL_WNDPROC, @SubClass_LV())
Repeat
ev = WaitWindowEvent()
Until ev=#WM_CLOSE
Good day

Not a destination
Switch the SubClass_LV() function for the following :
**EDIT : altered the code.
Code: Select all
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If msg = #WM_RBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = lparam&$ffff
HitInfo\pt\y = lparam>>16&$ffff
SendMessage_(lv,#LVM_SUBITEMHITTEST,0,@HitInfo)
GetNewText(hitinfo\iitem,hitinfo\iSubItem)
Debug hitinfo\iitem
Debug hitinfo\iSubItem
EndIf
ProcedureReturn result
EndProcedure
I may look like a mule, but I'm not a complete ass.
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Thanks, Thanks, Thanks, Thanks, Thanks, Thanks, Thanks, Thanks
You never know why, i thanks you
It's so difficult for me, and apparently so easy for you
I wish you the most best good day of the word
Thanks you very much for your precious help day by day, and the shared of your great knowledge
You never know why, i thanks you

It's so difficult for me, and apparently so easy for you

I wish you the most best good day of the word

Thanks you very much for your precious help day by day, and the shared of your great knowledge


Not a destination
No, what you did in moving the listicon was upset the (x, y) coordinates being used in the hittest. The #LVM_SUBITEMHITTEST message requires coordinates to be given relative to the listicon's client area itself which is exactly what the #WM_RBUTTONDOWN message provides in it's lParam parameter anyhow! 

I may look like a mule, but I'm not a complete ass.
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
I have again a problem
Thanks to you, i have switched the procedure subclass and that's fine
I have also remove the select case, because it's limited to 3 column.
But my new problem, is that, when i click on a empty cell, the selection is big because the variable "hitinfo\iItem" is again at -1
and with this code, i can't write in an empty cell

Thanks to you, i have switched the procedure subclass and that's fine

I have also remove the select case, because it's limited to 3 column.
But my new problem, is that, when i click on a empty cell, the selection is big because the variable "hitinfo\iItem" is again at -1

and with this code, i can't write in an empty cell

Code: Select all
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
Global oldlist,lv
Procedure.s GetNewText(item,subitem,xpos)
OpenWindow(1, xpos + 150,DesktopMouseY()+10,260,20,"",#PB_Window_BorderLess)
GetWindowRect_(WindowID(1), editrect.rect)
ClipCursor_(editrect)
CreateGadgetList(WindowID(1))
StringGadget(1,0,0,190,20,"")
ButtonGadget(2,190,0,30,20,"OK")
ButtonGadget(3,220,0,40,20,"Cancel")
SetActiveGadget(1)
AddKeyboardShortcut(1,#PB_Shortcut_Return,1)
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,RGB(200,200,200),subitem)
quit=0
Repeat
ev=WaitWindowEvent()
If EventWindow()=1
Select ev
Case #PB_Event_Menu
If EventMenu()=1
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
EndIf
Case #PB_Event_Gadget
If EventGadget()=2
SetGadgetItemText(0,item,GetGadgetText(1),SubItem)
CloseWindow(1)
quit = 1
ElseIf EventGadget() = 3
CloseWindow(1)
quit = 1
EndIf
EndSelect
EndIf
Until quit
SetGadgetItemColor(0,item,#PB_Gadget_BackColor,#White,subitem)
ClipCursor_(0)
EndProcedure
Procedure SubClass_LV(hwnd, msg, wparam, lparam)
Result = CallWindowProc_(oldlist, hwnd, msg, wparam, lparam)
If Msg = #WM_RBUTTONDOWN
HitInfo.LVHITTESTINFO
Hitinfo\pt\x = lparam & $ffff
HitInfo\pt\y = lparam >> 16&$ffff
SendMessage_(lv, #LVM_SUBITEMHITTEST, 0, @HitInfo)
GetNewText(hitinfo\iItem, hitinfo\iSubItem, Hitinfo\pt\x)
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"ListIcon Gadget Mischief: Edit Selected Item",$CF0001)
CreateGadgetList(WindowID(0))
lv = ListIconGadget(0,0,100,640,280,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",210)
AddGadgetColumn(0,3,"Column 3",215)
For i = 1 To 12
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
oldlist=SetWindowLong_(lv, #GWL_WNDPROC, @SubClass_LV())
Repeat
ev = WaitWindowEvent()
Until ev=#WM_CLOSE

Not a destination