
Editing cells in ListIcons (updated for Vista)
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Thanks.nicksteel wrote:Neat code![]()
![]()
![]()
I've never tried this, but I reckon it can be done; albeit with quite a bit of work. You'll need to subclass the listicon and intercept the #WM_HSCROLL messages and process these yourself. You'll then need to send the #LVM_SCROLL message in order to scroll by the required amount etc. Yep, this will be very fiddly indeed, particularly when dealing with the user dragging the thumb etc.Is there any way to align the first displayed column to the start of the cell (like in Excel) when horizonal scrolling? So that the entire first cell is always shown?
With my egrid library (which uses listicons) I took control of the scrolling just to speed things up and reduce the flicker etc. so I went part of the way towards your goal. I also ensure that whenever the user selects a cell, that the egrid is scrolled just enough to ensure that the whole cell is visible. Again, this would be similar to what you are looking for, but not quite as fiddly.
To be honest though, I never really saw the need to constantly ensure that cells within the first visible column were completely visible.
The first method would be to not enable column drag in the first place!...and,
Is there any way to disable dragging the column?

Alternatively, use
Code: Select all
#LVM_SETEXTENDEDLISTVIEWSTYLE = #LVM_FIRST+ $36
#LVS_EX_HEADERDRAGDROP = $10
SendMessage_(GadgetID(#ListIcon), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_HEADERDRAGDROP,0)
I may look like a mule, but I'm not a complete ass.
Thanks, Master of Grids.
You have attacked a real "hole" in PB!
Obviously I'll just buy Egrid if I need to write something serious and avoid all the headaches. Am having a learning experience at present, trying to understand PB's potential to solve my db needs.
Am just used to Clipper browse (non- windows of course) with its Excel like skipping column to column horizonal scrolling.
Your code is WAY over my head
, but a lot of fun to play with and a good way of gaining knowledge. 
Your efforts and patience are appreciated.

How is it enabled in ListIcon?The first method would be to not enable column drag in the first place!
Obviously I'll just buy Egrid if I need to write something serious and avoid all the headaches. Am having a learning experience at present, trying to understand PB's potential to solve my db needs.
Am just used to Clipper browse (non- windows of course) with its Excel like skipping column to column horizonal scrolling.
Your code is WAY over my head


Your efforts and patience are appreciated.
Slow, but trying.
Ah, are you talking about preventing the user from reordering columns by click and drag (in which case use the snippet above) or preventing the user from resizing columns by dragging the column divider?
In the latter case, look at the #HDN_BEGINTRACK, #HDN_BEGINTRACKW message handler in the code in my first post. This shows how to prevent the resizing.
However, this doesn't deal with the user double-clicking the divider and resizing the column that way. Even more difficult to control is the fact that Windows will continue to display the resizing cursor even when you've taken steps to prevent the columns from being resized.
Dealing with these last two problems requires that you subclass the header control which is attached to the listicon. I could possibly hack up an example for you, but it will take some time because I'm immensely busy right now.
In the latter case, look at the #HDN_BEGINTRACK, #HDN_BEGINTRACKW message handler in the code in my first post. This shows how to prevent the resizing.
However, this doesn't deal with the user double-clicking the divider and resizing the column that way. Even more difficult to control is the fact that Windows will continue to display the resizing cursor even when you've taken steps to prevent the columns from being resized.
Dealing with these last two problems requires that you subclass the header control which is attached to the listicon. I could possibly hack up an example for you, but it will take some time because I'm immensely busy right now.
I may look like a mule, but I'm not a complete ass.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
In the spirit of not intruding upon srod's immense busyness (-wii?), here's how to prevent all resizing of a listicon header. Note that you can drill down into the structure to manage only specific header buttons with *nmHEADER\iItem if you desire. This example just locks the whole thing:
@Freak, if you see this, using 4.10b2, the waitwindowevent() never changed case
Code: Select all
Global oldproc
Procedure ListProc(hwnd, msg, wparam, lparam)
Select msg
Case #WM_NOTIFY
*nmHEADER.HD_NOTIFY = lParam
Select *nmHEADER\hdr\code
Case #HDN_BEGINTRACKW, #HDN_DIVIDERDBLCLICKW
ProcedureReturn #True
EndSelect
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
OpenWindow(0,0,0,320,240,"Locked ListIcon Header",$CA0001)
CreateGadgetList(windowid(0))
ListIconGadget(0,0,0,320,240,"Col 0", 110)
AddGadgetColumn(0, 1, "Col 1", 100)
AddGadgetColumn(0, 2, "Col 2", 100)
oldproc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @ListProc())
Repeat:Until waitwindowevent()=#WM_CLOSE
BERESHEIT
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Here we are then. A joint netmaestro/srod production:
This will need refining slightly if you only prevent certain columns from being resized but allows others to be sized etc.
Code: Select all
#LVM_GETHEADER = #LVM_FIRST+31
Global oldproc, gOldHeaderProc
Procedure ListProc(hwnd, msg, wparam, lparam)
Select msg
Case #WM_NOTIFY
*nmHEADER.HD_NOTIFY = lParam
Select *nmHEADER\hdr\code
Case #HDN_BEGINTRACKW, #HDN_DIVIDERDBLCLICKW
ProcedureReturn #True
EndSelect
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
Procedure headerproc(hwnd, msg, wparam, lparam)
Protected result
Select msg
Case #WM_SETCURSOR
result = 0
Default
result =CallWindowProc_(gOldHeaderProc, hwnd, msg, wparam, lparam)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,320,240,"Locked ListIcon Header",$CA0001)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,320,240,"Col 0", 110)
Global gOldHeaderProc = SetWindowLong_(SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0), #GWL_WNDPROC, @headerproc())
AddGadgetColumn(0, 1, "Col 1", 100)
AddGadgetColumn(0, 2, "Col 2", 100)
oldproc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @ListProc())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
Last edited by srod on Wed Jun 20, 2007 3:37 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada