Extended ListIconGadget styles

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hi,

Found some more info in msdn.microsoft.com about list view styles. Test the chaotic following code:

Code: Select all

lvc.LV_COLUMN

lvc\imask = #LVCF_FMT

Structure LVITEM ; the real LVITEM structure is larger, but we don't need the discarded members for this example
  mask.l; 
  iItem.l; 
  iSubItem.l; 
  state.l; 
  stateMask.l; 
EndStructure

lpl.LVITEM
lpl\mask = #LVIF_STATE

#LVM_SETEXTENDEDLISTVIEWSTYLE = #LVM_FIRST + 54
#LVM_GETEXTENDEDLISTVIEWSTYLE = #LVM_FIRST + 55
#LVS_EX_GRIDLINES = 1
#LVS_EX_FULLROWSELECT = $20
#LVS_EX_HEADERDRAGDROP = $10
#LVS_EX_ONECLICKACTIVATE = $40
#LVS_EX_UNDERLINEHOT = $800
#LVS_EX_CHECKBOXES = 4
#LVIS_STATEIMAGEMASK = $F000

lpl\stateMask = #LVIS_STATEIMAGEMASK

InitGadget(1)

If OpenWindow(1,#CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"ListIconGadget column align example")

  LVWidth = WindowWidth() - 4
  
  If CreateGadgetList(WindowID())
    ListIconGadget = ListIconGadget(0, 0, 0, LVWidth, WindowHeight()-30, "This", LVWidth/4-1)
    AddGadgetColumn(0, 1, "is", LVWidth/4-1)
    AddGadgetColumn(0, 2, "a", LVWidth/4-1)
    AddGadgetColumn(0, 3, "test", LVWidth/4-1)
  EndIf

  col = 1
  lvc\fmt = #LVCFMT_RIGHT
  SendMessage_(ListIconGadget, #LVM_SETCOLUMN, col, @lvc)
  col = 2
  lvc\fmt = #LVCFMT_CENTER
  SendMessage_(ListIconGadget, #LVM_SETCOLUMN, col, @lvc)
  col = 3
  lvc\fmt = #LVCFMT_LEFT ; not really needed, left is the default
  SendMessage_(ListIconGadget, #LVM_SETCOLUMN, col, @lvc)

  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_GRIDLINES, -1) ; show grid lines
  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_FULLROWSELECT, -1) ; the entire row is highlighted when the item is selected
  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_HEADERDRAGDROP, -1) ; allows manual column reordering
  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_ONECLICKACTIVATE, -1) ; the following two underline hovered items
  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_UNDERLINEHOT, -1)
  SendMessage_(ListIconGadget, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_CHECKBOXES, -1) ; show checkboxes for every item

  AddListIconGadgetItem(0, 0, "Column 1"+Chr(10)+"Column 2"+Chr(10)+"Column 3"+Chr(10)+"Column 4", 0)
  AddListIconGadgetItem(0, 1, "The first column"+Chr(10)+"must"+Chr(10)+"always"+Chr(10)+"be", 0)
  AddListIconGadgetItem(0, 2, "left aligned,"+Chr(10)+"the others"+Chr(10)+"may"+Chr(10)+"not.", 0)

  Repeat

    EventID.l = WaitWindowEvent()

    Select EventID
      Case #PB_EventGadget
        row = 0 ; for example (this is just to demonstrate the use of List View checkboxes)
        state = SendMessage_(ListIconGadget, #LVM_GETITEMSTATE, row, #LVIS_STATEIMAGEMASK) >> 12 ; retrieves checkbox state
        MessageRequester("Row " + Str(row) +" checkbox state:", Str(state), 0)
        lpl\iItem = row
        lpl\state = 1 << 12 ; 0 disables the checkbox, 1 clears it, 2 sets it
        SendMessage_(ListIconGadget, #LVM_SETITEMSTATE, row, @lpl) ; sets checkbox state
      Case #PB_EventCloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf

End     
Enjoy it! Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.

El_Choni,

This is best and work fine in my proect.
Thanks,
Manolo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
Hi,

Found some more info in msdn.microsoft.com about list view styles. Test the chaotic following code:

Enjoy it! Bye,

El_Choni
Hello El_Choni, this is a problem i've had with this sort of code before... I can click on any other collumn and get the status of collumn 0 checkbox returned to me!!

I'm coding a tiny app and when I click on a collumn with this method, it always goes south after the first click.

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hmm, I don't understand it very well. You can get the state by one side, and the checkbox state by other. The snippet I posted is to retrieve the second. I think that GetGadgetState() retrieves the first in this case, but I'm not sure of what is exactly your problem.

What does "goes south" mean? (apart from its literal meaning, I'm not a native english speaker, it takes me more time to understand some expressions).

Bye,



El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Hi Fang. I've take a look to your code and you call a second time InitGadget(). That's causing the fault. And all gadgets must have a different ID. ListIcon finally works correctly :).

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
Hi Fang. I've take a look to your code and you call a second time InitGadget(). That's causing the fault. And all gadgets must have a different ID. ListIcon finally works correctly :).

Fred - AlphaSND
I worked that one out with Paul's help. The events in everyone's examples still don't fire correctly though. Paul tried the GUI library, that's not working properly either (unless he made the same mistakes I did) :):)

First rule, after fixing mistakes is to make sure gadget is activated (set focus) but, all the ListIconGadget examples I have tried have all misbehaved so I know I am not going crazy (yet) !! :):)

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

Hi, I've started playing with ListIcons as well but mine keeps giving me a KERNEL32.DLL Page Fault. It seems to be specifically when I do a series of AddListIconGadgetItem()'s.

I posted my code up in "Bug Reports", but I'm not sure if this is Windows problem of a Purebasic problem. Get the same error under both W95 & W2000, though - has anyone any ideas? I'm a bit of a PB newbie...

Cheers - NAW
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

???ListIcons???

- I meant "GadgetList" - been a long day & I've been staring at the screen too long :wink:
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.

El_Choni,
I need see the last row permanently in ListIconGadget, because I work in the
last + 1 line.
For example:
If you fill all rows of the ListIcon, to righ bar only scroll if you work with the mouse.
You understand??
Ok frend, work and see the possible solution for me. hehehe.
Regards.
Manolo
[url]mailto:vpardo@infonegocio.com[/url]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.

El_Choni
Today 22.30 GMT FOOOOOOTTTTTBAAAAAALLL

Celta de Vigo vs Deportivo de La Coruña (Depor)

AUTPAAAAA DEPORRRRR....

Manolo
[url]mailto:vpardo@infonegocio.com[/url]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

AUPA DEPOR! We won, if you wanna know...

No, Manolo, I don't understand, I'm very sorry. Feel free to send me your question in galego to my e-mail, if I find the answer and it's interesting I'll post it here.

Bye,

El_Choni
Post Reply