Page 1 of 1
GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 11:47 am
by infratec
Dear Team,
it looks that the procedure GetGadgetItemAttribute(GadgetNo, 0, #PB_ListIcon_ColumnWidth, i)
is not reliable.
But I can not find out on what it depends.
On my PCs it works correct.
On Demivecs PC with the same OS and the same SP it returns something but not what it should.
Please look here:
http://www.purebasic.fr/english/viewtop ... 12&t=40457
This was also noticed in the german forum:
http://www.purebasic.fr/german/viewtopic.php?t=14364
But the windows API function seems to work always correct:
SendMessage_(GetWindow_(GadgetID(GID),#GW_CHILD),#HDM_GETITEMCOUNT,0,0)

It is not cross platform.
Please check this
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 12:40 pm
by gnozal
Hmm, I don't understand your post :
. #PB_ListIcon_ColumnWidth returns the width of the given column
. #HDM_GETITEMCOUNT counts of the items in a header control (no native PB function iirc : maybe this is your wish ?)
These are two different things.
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 1:04 pm
by infratec
Hi gnozal,
What I want:
I want to get the numbers of columns of the ListIconGadget.
Since there is no direct PB solution, I tried to find it out with the
GetGadgetItemAttribute() procedure.
The idea: increase the columnnumber until it returns 0 or -1.
the API stuff it's not from me.
It's the latest answer from the german forum entry.
But I just checked it, and it returns the number of the columns.
So it does what I want... but not in a cross platform PB way.
Bernd
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 1:12 pm
by gnozal
infratec wrote:I want to get the numbers of columns of the ListIconGadget.
Since there is no direct PB solution, I tried to find it out with the
GetGadgetItemAttribute() procedure.
The idea: increase the columnnumber until it returns 0 or -1.
Thanks, I understand now.
You wish a native (multi-platform) HDM_GETITEMCOUNT like function.
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 1:40 pm
by Marco2007
Why not just doing something like this for adding columns?
Code: Select all
Global f=1
Procedure AddListIconColumn(gadget, Position, text.s, width)
AddGadgetColumn(gadget, Position, text, width) : f+1
EndProcedure
f-1...for removing columns.
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 2:04 pm
by ts-soft
Marco2007 wrote:Why not just doing something like this for adding columns?
Code: Select all
Global f=1
Procedure AddListIconColumn(gadget, Position, text.s, width)
AddGadgetColumn(gadget, Position, text, width) : f+1
EndProcedure
f-1...for removing columns.
In a Includefile or UserLib for other Users you haven't access to the creation of Colums

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 2:18 pm
by mk-soft
I do not think it give column without text.
Code: Select all
Procedure GetGadgetColumnCount(Gadget)
Protected index
index = -1
Repeat
index + 1
Until GetGadgetItemText(Gadget, -1, index) = ""
ProcedureReturn index
EndProcedure
GT

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 2:34 pm
by ts-soft
mk-soft wrote:I do not think it give column without text.
GT

Why do you think so? I use often column without title.
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 3:07 pm
by Marco2007
Maybe, something like this:
Code: Select all
Procedure CountListiconColumn(gadget, maxcolumn, keyword.s)
If IsGadget(gadget)
AddGadgetColumn(gadget, maxcolumn, keyword, 0)
For i=0 To maxcolumn
If GetGadgetItemText(gadget, -1, i)=keyword
Break
EndIf
Next
RemoveGadgetColumn(gadget, i)
ProcedureReturn i
EndIf
EndProcedure
If OpenWindow(0,0,0,400,550, "",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListIconGadget(0,20,0,365,500, "1", 90,#PB_ListIcon_GridLines)
For j = 1 To 100
AddGadgetColumn(0, j, Str(j+1), 90)
Next
For j = 1 To 10
AddGadgetItem(0,-1,"Links"+Str(j) + #LF$ + "Mitte" + #LF$ + "Rechts")
Next
Debug CountListiconColumn(0, 32767, "__thiscolumnwillbejustaddedtocountthecolumns__@@__unique_name__1234567890")
Repeat ;
EventID=WaitWindowEvent()
Until EventID=#PB_Event_CloseWindow
EndIf
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Thu Dec 31, 2009 4:43 pm
by freak
> I want to get the numbers of columns of the ListIconGadget.
then this is a feature request, not a bug report.
Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Fri Jan 01, 2010 2:24 pm
by infratec
Hi freak,
this was only an explanation what I want to do.
Than I found that the GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth procedure
has a 'bug' (not working on all platforms as expected)
So in my opinion it is a bug, and nothing for the wishlist.
Bernd
P.S.: A happy new year!
Oh, it's already back in the bug section. Sorry

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth
Posted: Fri Jan 01, 2010 2:38 pm
by freak
The attribute is not intended for counting the columns. If you use it for the wrong purpose you shouldn't be surprised if it doesn't work.