Hi,
should be a simple question at first glance, but apparently there is no documented way to get the text length of a (sub)item of a listview in report mode without getting the text as well. Or am I wrong?
Japheth
should be a simple question at first glance, but apparently there is no documented way to get the text length of a (sub)item of a listview in report mode without getting the text as well. Or am I wrong?
Japheth
Same problem here. :(
This is crazy since you have to speciffy buffer to contain subitem text to count it's length. Realy i would like to meet guy who designed ListView Report.
I will consider Custom ListView in near future since default one so lack.
Is there a way to get acces to the place in memory with ListView informations ??
I will consider Custom ListView in near future since default one so lack.
Is there a way to get acces to the place in memory with ListView informations ??
There's a way to get the length of the item text without retrieving the text :) This cannot be done for subitem...
[COLOR=teal][b];(C) 2003 Morris :)[/b][/COLOR]
[COLOR=blue][b]invoke[/b] SetFocus[/COLOR],hListView
[COLOR=blue][b]invoke[/b] SendMessage[/COLOR],hListView,[COLOR=blue]LVM_EDITLABEL[/COLOR],iItemNumber,0
[COLOR=blue][b].if[/b][/color] [COLOR=orange]eax[/COLOR]
[COLOR=teal][b];we have the hWnd of the edit box which is used to edit the item, so why not get the text lenght? :)[/b][/COLOR]
[COLOR=blue][b]invoke[/b] SendMessage[/COLOR],[COLOR=orange]eax[/COLOR],[COLOR=blue]WM_GETTEXTLENGTH[/COLOR],0,0
mov iTextLength,[COLOR=orange]eax[/COLOR]
[COLOR=blue][b].endif[/b][/color]
[COLOR=teal][b];cancel edit[/b][/color]
[COLOR=blue][b]invoke[/b] SendMessage[/COLOR],hListView,[COLOR=blue]LVM_EDITLABEL[/color],-1,0
This method however produces some unwanted effect (selected listview item flashes).regards
Dont tell me.......
No i will not belive it :tongue:
That's a good one Moris i will remember it.
Somebody knows max length of ListView Item text ???
you can save the Text's Lenght as the item's data (LPARAM lParam; // 32-bit value to associate with item ) (if you don't use it).
you can save the Text's Lenght as the item's data (LPARAM lParam; // 32-bit value to associate with item ) (if you don't use it).
Nice thanks.
I'm using lParam but i think that i can spare 16 bit for length.
Maby it was to early to flame that control so much :tongue:
Hi, guys. You might find this interesting...
There is another way to do it, based on a trial and error approach.
http://www.asmcommunity.net/board/showthread.php?threadid=14524&highlight=get+text+length
There is another way to do it, based on a trial and error approach.
http://www.asmcommunity.net/board/showthread.php?threadid=14524&highlight=get+text+length
Qvasimodo,
The original question was:
The trial-and-error method requires to retrieve the text to check its length.
The original question was:
Originally posted by japheth
apparently there is no documented way to get the text length of a (sub)item of a listview in report mode without getting the text as well. Or am I wrong?
apparently there is no documented way to get the text length of a (sub)item of a listview in report mode without getting the text as well. Or am I wrong?
The trial-and-error method requires to retrieve the text to check its length.
Duh... :o
:stupid:
:stupid:
Originally posted by wizzra
you can save the Text's Lenght as the item's data (LPARAM lParam; // 32-bit value to associate with item ) (if you don't use it).
This will work only for item's text, but not for subitems' texts (subitems do not support the LVITEM.lParam member).
you can save the Text's Lenght as the item's data (LPARAM lParam; // 32-bit value to associate with item ) (if you don't use it).
Anyway, I have some idea about getting the length of (sub)item's text without getting the text. I'll publish it when I do some tests :)
Hi Morris,
yes indeed, but you can do a little trick.
if your text is not over 256bytes and u have x<=4 columns, u can use the LPARAM lparam to save upto 4 diff column's text lengths (1main column + 3 subitems) for each row.
15385FFFh ;)
item text = 15h
sub item 1 = 38h
sub item 2 = 5Fh
sub item 3 = FFh
yes indeed, but you can do a little trick.
if your text is not over 256bytes and u have x<=4 columns, u can use the LPARAM lparam to save upto 4 diff column's text lengths (1main column + 3 subitems) for each row.
15385FFFh ;)
item text = 15h
sub item 1 = 38h
sub item 2 = 5Fh
sub item 3 = FFh
but if u have only 256 max length you can provide such a short buffer without hessitation plus speed will be satysfying also.
If you really need more text and/or subitems, you can allocate enough memory to store the lenghts of each string and place the pointer in lParam. (I hope this makes up for my useless post before :grin: ).
If you really need more text and/or subitems, you can allocate enough memory to store the lenghts of each string and place the pointer in lParam. (I hope this makes up for my useless post before :grin: ).
Idea is good but it will make it more complex, we are serching the easiest way to do this.
1. You will not know how many items there will be so who knows how big the buffer will be (BTW it's realy bugging me when i cant specify exact buffer size).
2. There will be a problem with SubItems maby we will add new columns later.
3. A lot of new ListViews==A lot of new buffers.
You have a point, it would be more complex. However all the other problems can be solved... if you add a new column, you have to reallocate all of your "buffers". This may be a problem, though, depending on how you're allocating this data...
As for not knowing the size of the array of pointers, it's enough to store the size in the first DWORD. :)
Still the idea is only good for a fixed number of columns, though. Otherwise it's more trouble than it's worth. :(
Hey, but at least I said something useful this time, it's an improvement. :grin:
As for not knowing the size of the array of pointers, it's enough to store the size in the first DWORD. :)
Still the idea is only good for a fixed number of columns, though. Otherwise it's more trouble than it's worth. :(
Hey, but at least I said something useful this time, it's an improvement. :grin:
Originally posted by AceEmbler
Is there a way to get acces to the place in memory with ListView informations ??
Is there a way to get acces to the place in memory with ListView informations ??
Hmmm, it took me a while to do some research on this... Are you still interested? :)
Naturally :)
Well, basically to get to the internal ListView structure you simply have to
I've checked comctl32.dll versions from 4.00.950 to 6.0.2800.1106 (with some exceptions, see the attachment). I did not bother to demystify all members of the LV_DATA structure, only those that were easy to guess by their contents. Maybe in the future I'll look at it a bit closer. Any comments welcome.
invoke GetWindowLong,hListView,0
But here's where it starts to be complicated. From version to version this structure has ben changed, and to my current knowledge, there are seven variants of this, let's call it, LV_DATA.
I've checked comctl32.dll versions from 4.00.950 to 6.0.2800.1106 (with some exceptions, see the attachment). I did not bother to demystify all members of the LV_DATA structure, only those that were easy to guess by their contents. Maybe in the future I'll look at it a bit closer. Any comments welcome.