May 01, 2024, 08:22:51 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Editable cells in a listview control

Started by srod, July 31, 2007, 05:30:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

srod

July 31, 2007, 05:30:33 AM Last Edit: July 31, 2007, 06:50:42 AM by srod
Hi,

as a good means of getting to grips with EMBasic, I grabbed one of my Purebasic utilities almost at random and converted it to EMBasic (whilst beefing it up a little). I've got to say that with the assistance of the EMB help manual and these forums, it was a breeze. EMB appears very solid indeed (and I love these c-style pointers! Never realised just how powerful pointers could be before now!)

What we have then is a little utility that allows any cell in a listview control to be directly edited by the user. It's quite simple and whilst not in the same league as a grid control, it's quite effective anyhow and quite suitable for those applications just requiring basic editing of cells etc.

It works as follows:

Basically, a Windows list view control allows you to edit the labels in column zero if you set the LVS_EDITLABLES style and, at a minimum, process the LVN_ENDLABELEDIT message. What my library does on intercepting a double-click on a valid cell, is instruct Windows to edit the corresponding label in column 0, but before Windows has a chance to position the edit control used to actually edit the label, the library manages to grab a hold of the control and reposition it over the selected cell etc. On completion of the editing process, I just switch the text in the cell for that in the edit control etc. I also take steps to scoll the listview if the user double clicks a cell which is only partly visible.

It's not perfect, but as I say it is simple.

http://www.purecoder.net/List View editable.zip

Note that for various reasons, to use this library with any listview control, you must set column zero to have a zero width. This is to prevent some poor behaviour on Windows part when the user clicks a row.  See the demo program enclosed in the zip.

Stephen.

mrainey

Software For Metalworking
http://closetolerancesoftware.com

srod

Quote from: mrainey on July 31, 2007, 06:29:38 AM
Thanks for that one.


You're welcome. As I say, coding this has taught me a lot about EMBasic!  ;D

Haim

Hello,
Somehow the link does not work for me.
I get a message that the link is invalid

Any suggestion for what I should do?

haim

srod

Uhm, for some reason nothing happens if I click the link!

Still, works if I copy and paste the url etc. Try that.

Rock Ridge Farm (Larry)

Cut the link and paste it to your browser - I had the same problem after the last firefox update.
I am also having problems with many web sites today - Could the web be sick?


srod


Haim


splakidas

if i change the number of columns from 30 to 400


For col = 1 To 400
    CONTROLCMD  w1, 1, @LVINSERTCOLUMN, col, "Col "+Str$(col)
    CONTROLCMD  w1, 1, @LVSETCOLWIDTH, col, 100
Next col


then you are not able to see numbers greater than 328 on the top of the listview
it is possible to work ?

srod

Quote from: splakidas on August 01, 2007, 08:58:37 AM
if i change the number of columns from 30 to 400


For col = 1 To 400
    CONTROLCMD  w1, 1, @LVINSERTCOLUMN, col, "Col "+Str$(col)
    CONTROLCMD  w1, 1, @LVSETCOLWIDTH, col, 100
Next col


then you are not able to see numbers greater than 328 on the top of the listview
it is possible to work ?


A windows limitation of the header control is that it's total width must not exceed 32767 pixels (16-bit). So it is not the number of columns which is the problem, but the total width of all the columns.  In fact you'll see that 327 columns each of width 100 pixels renders correctly (total width 32700) but the 328th header item does not.  As soon as you exceed this limit then the header begins to misbehave!  This is the case for all listview controls.

Nothing we can do therefore except remove the header from the listview control and use the first row of the listview to simulate the header cells.

The reason for all this is that the header control actually has a client area equal in size to the sum of all widths of the header cells. This seems a strange way of doing it to me, probably a throw back to earlier versions of windows. I do think the header control is due a revamp.  :)



JimH

Stephen -

Thanks for the interesting code - and especially for the liberal comments throughout!

It is so much easier to learn when the coder tells you what he's doing instead of making you guess.  :P

   <*> Jim

srod

Quote from: JimH on August 01, 2007, 09:52:56 PM
Stephen -

Thanks for the interesting code - and especially for the liberal comments throughout!

It is so much easier to learn when the coder tells you what he's doing instead of making you guess.  :P

   <*> Jim

You're welcome Jim.