News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

LB_FINDSTRING

Started by Grincheux, March 19, 2005, 03:16:10 PM

Previous topic - Next topic

Grincheux

Hello, :bdg

My program uses a LISTBOX. Above this LISTBOX there is an EDIT field for searching items. And this is my problem.
When I use LB_FINDSTRING the answer is OK if the text in the LISTBOX begins with the same text as in the EDIT field.

But I use this field to search any text and in this case I have no solution.

Do I have to subclass the LISTBOX ?

Thanks for your help.

Philippe RIO
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

AeroASM

AFAIK, Windows does not provide the function you are looking for, so you need to write your own algorithm to manually retrieve the text from each item of the listbox and check if it contains the text you are looking for. If you need help with this, let me know.

You do not need to subclass, and I would not advise it in this particular instance (because you are only doing it for one listbox).

Grincheux

I accept your help. :dance:

I thought I had to browse all the listbox (nearly 50 000 items !), and to search the text using regular expression ?

But I have nothing for doing that !

And that could take a long time.

Thanks

Philippe RIO
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz


Grincheux

This is not what I want to do.

I explain :

I am using an extended selection in the listbox (LBS_EXTENDEDSEL style).
So I want to select one or more than one.
In a listbox I have more than 50 000 items which are news groups.
If I want to select all the items which have "pictures" or "mp3" anywhere in their names, I can't use LB_FINDSTRING.
LB_FINDTRING gives only the first string that matches the search criteria.
LB_SELECTSTRING is not good for my work too.
What is the other way to select many items ?
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

MichaelW

Quote
wParam
Specifies the zero-based index of the item before the first item to be searched.

I interpret this statement to mean that you find multiple strings by repeatedly sending the message with wParam set to the index of the last matching string found.

If you need to find strings that contain some sub string, I can see no way other than:
LB_GETTEXTLEN
Allocate a buffer
LB_GETTEXT
InString
LB_SETSEL if substring found

I timed the MASM32 InString procedure and on a P3-500 it can fully process ~1.3 million 100-byte strings per second. Judging from this, I think 50,000 strings could be retrieved from the list box and searched in not more than a few seconds even on a slow system.
eschew obfuscation

Grincheux

I know this method, but thought it would not give me what I am searching for.
With your answer I will program it.
If you say it is fast I can implement it.

Thanks
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Relvinian

This is more of a design answer then giving code to help you out.

If you have a LOT of items that you want to display and select (like a lisitng of all the newsgroup on a server), you may want to think about using a List Control (virtual style) to display your data.  A virtual list control doesn't know about the data it contains and makes a call back to display items which are visible on the screen.  With this, you can keep your stuff in some type of an array (sorted how you like, etc) and do quick searching on your own structure of information.  The list control will just display what is visible.

Something to think about for performance reasons.

Relvinian

Grincheux

 :U
I have never used this kind of control.

I will take a look about it.


Thanks
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Grincheux

MichaelW gave me a solution I have implemented. It runs fine and is very fast.

Thanks.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz