Window ListIconGadget With Owner Data (Very Fast)

Share your advanced PureBasic knowledge/code with the community.
User avatar
ChrisR
Addict
Addict
Posts: 1528
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by ChrisR »

Nicely done, thank you for sharing :)
UpdateListIconGadget after all AddGadgetItem, SetGadgetItemState or SetGadetItemColor, makes the difference for speed
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by mk-soft »

Update v1.04.7
- Changed max columns count to auto column count

The count of columns is no longer limited and the item data is automatically adjusted.
The constant #LISTICON_COLUMN_SIZE indicates the starting value of the created columns
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by mk-soft »

ChrisR wrote: Sun Jan 04, 2026 12:53 pm Nicely done, thank you for sharing :)
UpdateListIconGadget after all AddGadgetItem, SetGadgetItemState or SetGadetItemColor, makes the difference for speed
The biggest difference is the use of LVS_OWNERDATA. PureBasic needs about 300 ms to create 100000 items.
The ListView of MS several more than 50 seconds

;)
Last edited by mk-soft on Mon Jan 05, 2026 8:13 am, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5601
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Kwai chang caine »

Nice work 8)
Have you planed to make manually editables cells ?
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
HeX0R
Addict
Addict
Posts: 1231
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by HeX0R »

This would be a GridGadget and no ListIconGadget
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5601
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Kwai chang caine »

HeX0R wrote: Mon Jan 05, 2026 1:37 am This would be a GridGadget and no ListIconGadget
Aaaaah !!!
I hadn't noticed there was a difference. :oops:
So a gridgadget, is a manually editable listicongadget ?
And surely others options, but i don't know wich
So PB doesn't have Gridgadget, which is so useful. :|
Thanks HEXOR for have learning to me this différence 8)
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
HeX0R
Addict
Addict
Posts: 1231
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by HeX0R »

There were some quite good GridGadgets based on Canvas here in the forum, might be worth a search?
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 514
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Mindphazer »

Hi mk-soft
That's indeed, pretty fast !!
It takes about 10000 ms to fill a "standard" ListIconGadget with 20.000 elements, and... 31 ms with your method !

It will be very useful for me !!
Thanks a lot
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 26.1 - Iphone 17 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by mk-soft »

Update v1.05.1
- Added Item Images Support
- Bugfix AddGadgetColumn

I've expanded it a little bit ;)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
ChrisR
Addict
Addict
Posts: 1528
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by ChrisR »

Thanks for the improvements, images support, a nice ListIconGadgetEx :)
It would be a bonus if we could set colors on the header, as done here, of course, if it suits you
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5601
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Kwai chang caine »

HeX0R wrote: Mon Jan 05, 2026 12:47 pm There were some quite good GridGadgets based on Canvas here in the forum, might be worth a search?
Yes i know, there is several ListIcons manually modified on the forum, a style of basic EXCEL, because this subject really interesting me, since a long time, but :

1/ I didn't know that was called a GridGadget (For me ListIcon and GridGadget were the same thing, before you told me. :oops: )

2/ If I'm not mistaken, this Gridgadgets aren't based on virtual listicons.They're slow to load thousands of rows. :|
For the moment, unless I'm mistaken or have omitted something, i haven't find a working ListIcon very quick AND manually modified :cry:
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by mk-soft »

Not fast, but works ...

Said's Canvas GridGadget
Link: viewtopic.php?f=12&t=54022

Last Update v2.4:
Link: https://github.com/mk-soft-65/MyGrid

But this is about the ListIconGadget from PureBasic and not a GridGadget. :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5601
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Kwai chang caine »

Thanks Mksoft
Yes i have see this splendid code, furthermore creating with a canvas, so starting from nothing, all by drawing... incredible :shock:
But i search something like EXCEL able to load numerous thousand of lines the most faster possible, exactely like your or RASHAD nice code 8)
Unfortunately without cells editables :| ... This important function for me
I remember me, trying to modify the RASHAD code for adding this function, but like usually without succes :oops:
But now, thanks to HEXOR i have understand i must search virtual gridgadget for have this two functions together :wink:
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
Michael Vogel
Addict
Addict
Posts: 2835
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by Michael Vogel »

Great and slim - cool work, thank you.


I'll keep the version without image support also because this should include everything needed most of the time.
Maybe some flags like #ListIcon_EnableImageSupport combined with some CompilerIf could be used to create an all in one solution.

Editing cells would also add additional overhead even this functionality is not used. Maybe a simple StringGadget at the top/bottom outside the original code would be enough in some situations. I added a quick method to get the right column (windows only):

Code: Select all

; AddOn
Procedure GetRowColumn(listicon,*row.Integer,*col.Integer)

	Protected p.Point
	Protected handle
	Protected hCWnd
	Protected header
	Protected hi.LVHITTESTINFO

	GetCursorPos_(@p)
	handle=GadgetID(listicon)
	ScreenToClient_(handle,p)

	hCWnd=	ChildWindowFromPoint_(handle,p\y<<32 + p\x)
	header=	SendMessage_(handle,#LVM_GETHEADER,0,0)
	hi\pt=	p
	SendMessage_(handle,#LVM_SUBITEMHITTEST,0,@hi)

	If hCWnd And hCWnd<>header
		*row\i=hi\iItem
		*col\i=hi\iSubItem
		ProcedureReturn #True
	EndIf

	ProcedureReturn #Null

EndProcedure
A call within the gadget event loop could look like this then (just for demonstration, no editing can be done here):

Code: Select all

	Case #PB_EventType_LeftClick
		Protected row,col
		If GetRowColumn(0,@row,@col)
			StatusBarText(0,0,"R:"+Str(row)+" C:"+Str(col)+" = '"+GetGadgetItemTextEx(0,row,col)+"'")
		EndIf
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Window ListIconGadget With Owner Data (Very Fast)

Post by mk-soft »

Michael Vogel wrote: Wed Jan 07, 2026 3:52 pm Great and slim - cool work, thank you.


I'll keep the version without image support also because this should include everything needed most of the time.
Maybe some flags like #ListIcon_EnableImageSupport combined with some CompilerIf could be used to create an all in one solution.
Edit:
A #ListIcon_EnableImageSupport is not required. Only when an image is used, the required image list is created.
The time difference between the version with or without images is very small. Maybe a 1ms at 100000 items.

If you use the one without image support, you must clean up the AddGadgetColumn bug yourself.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply