Listicon: Anchor the first column (Updated April 24, 2010)

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Update March 28, code & details in first post
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Very nice; co complaints this time from me! :wink:

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

hehe, there is a complaint! If you scroll the horizontal bar over, then resize the column, you get an undesirable effect. This is because of the way I'm grabbing the button image, the DC has to be fully scrolled right to correctly get the image. If it isn't, it gets part of button 0 and part of button 1, etc. I am fully reworking this right now as part of the process of making button 0 pressable. Much better thing to come.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Update March 29, details & code in first post. Also, the demo prog is updated to test button presses for column 0.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Just tried this with gnozal's PureLVSort library, seems to work fine! (whew) :D

After I add support for #PB_ListIcon_Gridlines I'm going to call this pretty much done, unless I'm missing something.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

A clever way of getting the 3 button images netmaestro; very slick! :) Did you look at the uxTheme library as an alternative though - I presume you can render these images directly through this library (although I haven't checked this!) Hey, column 0 no longer jumps when you resize it! Yes, much better. 8)

A couple of minor glitches. With full row select, the text in the selected row in column 0 is black rather than the system highlight-text color. Looks a bit odd. Also, when the listicon loses focus, all cells in the selcted row lose the highlighted background, except column 0. Finally, switch off xp themes and the whole of column 0 has a gray background! Perhaps some of this is just Vista only.

Thanks again.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: Listicon: Anchor the first column (Updated Sun. March 29

Post by QuimV »

:shock:
it seems don't release resources
Test Code:

Code: Select all


IncludeFile "fixedicongadget.pbi"

OpenWindow(0,0,0,400,300,"FixedIconGadget Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)


  FixedIconGadget(0,10,10,380,280,"column 0", 140,#PB_ListIcon_FullRowSelect)
  FreeGadget(0)


Repeat
 Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow


QuimV
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Listicon: Anchor the first column (Updated Sun. March 29

Post by netmaestro »

I'll look at it later today, I'm very busy sorry.
BERESHEIT
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: Listicon: Anchor the first column (Updated Sun. March 29

Post by QuimV »

:D OK don't worry and Thanks
QuimV
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Listicon: Anchor the first column (Updated Sun. March 29

Post by netmaestro »

Update 24 April 2010: Corrected bugs preventing the gadget from responding to FreeGadget() properly. The gadget is freed completely now when it receives this command.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Listicon: Anchor the first column (Updated April 24, 201

Post by srod »

Nice. :)
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: Listicon: Anchor the first column (Updated April 24, 201

Post by QuimV »

@netmaestro,
:D Tested on WXPSP3+PB441 - WXPSP3+PB450B3 - W732+PB441 - W732+PB450 and all runs fine.
Thanks a lot
QuimV
troybowd
New User
New User
Posts: 2
Joined: Wed Mar 21, 2018 9:46 am

Re: Listicon: Anchor the first column (Updated April 24, 201

Post by troybowd »

First post here, so hi everyone. :D

I am writing a program in PB and have come to the stage where I need a ListIconGadget. This works fine for my purposes and I have no complaints, but I have been looking for a simple way to lock the first column.

This works fine using the code here, until I want to resize the ListIconGadget. It seems that it does not redraw properly. I changed the example provided to show the problem. Try resizing the window.

Does anyone know a fix for this so that I can lock the first column and dynamically resize the ListIconGadget based on the window size.

Thanks in advance for any help.

Code: Select all

Global old_proc

Procedure MyListProc(hwnd, msg, wparam, lparam) 

  Select msg 
    
    Case  #WM_NOTIFY 
      *nmHEADER.HD_NOTIFY = lParam 
       Select *nmHEADER\hdr\code 
        Case #HDN_ITEMCLICKW 
          Debug "Column "+Str(*nmHEADER\iitem)+" button pressed"
        EndSelect 
  EndSelect
  
  ProcedureReturn CallWindowProc_(old_proc, hwnd, msg, wparam, lparam)
EndProcedure


OpenWindow(0,0,0,200,200,"FixedIconGadget Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu| #PB_Window_SizeGadget)

List0 = FixedIconGadget(#PB_Any,10,10,600,300,"column 0", 140,#PB_ListIcon_FullRowSelect)

ResizeGadget(List0, 20,100,#PB_Ignore,600)
SetGadgetFont(List0, LoadFont(0, "Arial", 12) )

AddGadgetColumn(List0,1,"Column 1",100)
AddGadgetColumn(List0,2,"Column 2",100)
AddGadgetColumn(List0,3,"Column 3",100)
AddGadgetColumn(List0,4,"Column 4",100)
AddGadgetColumn(List0,5,"Column 5",100)
AddGadgetColumn(List0,6,"Column 6",100)
AddGadgetColumn(List0,7,"Column 7",100)

For i=0 To 100
  AddGadgetItem(List0, -1, "Line "+Str(i)+" First gadget column 0"+Chr(10)+"Line "+Str(i)+" col 1"+Chr(10)+"Line "+Str(i)+" col 2"+Chr(10)+"Line "+Str(i)+" col 3"+Chr(10)+"Line "+Str(i)+" col 4"+Chr(10)+"Line "+Str(i)+" col 5"+Chr(10)+"Line "+Str(i)+" col 6"+Chr(10)+"Line "+Str(i)+" col 7")
Next

old_proc = SetWindowLong_(GadgetID(list0),#GWL_WNDPROC,@MyListProc())


;ButtonGadget(0, 400,720,100,20,"Destroy")

Repeat
  ev = WaitWindowEvent()
  Select ev
    Case #PB_Event_Gadget
      If EventGadget()=0
        FreeGadget(List0)
      EndIf
    Case #PB_Event_SizeWindow
      ResizeGadget(List0,0,0,WindowWidth(0),WindowHeight(0))
  EndSelect
Until ev = #PB_Event_CloseWindow
troybowd
New User
New User
Posts: 2
Joined: Wed Mar 21, 2018 9:46 am

Re: Listicon: Anchor the first column (Updated April 24, 201

Post by troybowd »

I tried for many hours to get this code working with dynamic resizing, but never had any success. I'm assuming it's not possible without big changes.

Anyway, I worked around this issue for my own program by using a pair of standard ListIconGadgets. The first one has column 1, and the second one has the rest of the columns. Then I used a callback to synchronize the vertical scrolling. Each ListIconGadget is sitting on a ContainerGadget and the position/size is adjusted in such a way that the first ListIconGadget vertical scroll bar is hidden. Then I wrote a bunch of wrapper functions for moving, resizing, changing colours, setting and retrieving items, etc...

Not the cleanest way of doing it but it works well enough for what I need to do.

I am happy to share my code if requested, but I don't want to derail this thread as my idea is completely different to what is presented in here.

Thanks anyway. :D
Post Reply