Restored from previous forum. Originally posted by jreimers.
Hello, I´m new to PB, nevertheless I´ve to write some code for a client,
now I´ve 2 problems with listicongadget (PB 3.0):
1. Any idea about changing strings directly?
(something like get/setgadgettext, I´ve tried this, but does not work with listicongadget)
My workaround was to delete and then to add item, but that´s too slow
and seems to steal memory.
2. Since I use the listicongadget only for displaying purposes I don´t want
the user to be able to change text. I tried disablegadget, but it looks poor
grey and the scrollbar must be enabled!
Sorry for my poor english, I´m german.
Thanks for quick reaction
J. Reimers
URGENT Help for listicongadget needed!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Manolo.
Hi,
See the next example from El_Choni.
Hi,
See the next example from El_Choni.
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
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
Well, actuaqlly there's no way in the example to change the text. Here is it:
Don't know how to change enabled/disabled without DisableGadget(), sorry.
Bye,
El_Choni
Well, actuaqlly there's no way in the example to change the text. Here is it:
Code: Select all
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
pszText.l
EndStructure
lpl.LVITEM
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)
AddListIconGadgetItem(0, 0, "Column 1"+Chr(10)+"Column 2"+Chr(10)+"Column 3"+Chr(10)+"Column 4", 0)
AddListIconGadgetItem(0, 1, "text"+Chr(10)+"text"+Chr(10)+"text"+Chr(10)+"text", 0)
AddListIconGadgetItem(0, 2, "text"+Chr(10)+"text"+Chr(10)+"text"+Chr(10)+"text", 0)
lpl\mask = #LVIF_TEXT
lpl\iItem = 0 ; column
lpl\iSubItem = 1 ; file
lpl\pszText = @"new text"
SendMessage_(ListIconGadget, #LVM_SETITEMTEXT, row, @lpl) ; changes item text
EndIf
Bye,
El_Choni
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm