GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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)

:cry: It is not cross platform. :cry:

Please check this
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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. :cry:

Bernd
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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.
PureBasic for Windows
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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 :wink:
User avatar
mk-soft
Always Here
Always Here
Posts: 6206
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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 :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
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post by ts-soft »

mk-soft wrote:I do not think it give column without text.
GT :wink:
Why do you think so? I use often column without title.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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
PureBasic for Windows
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post by freak »

> I want to get the numbers of columns of the ListIconGadget.

then this is a feature request, not a bug report.
quidquid Latine dictum sit altum videtur
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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 :oops:
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: GetGadgetItemAttribute() with #PB_ListIcon_ColumnWidth

Post 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.
quidquid Latine dictum sit altum videtur
Post Reply