Yes, I have the default working in my main program, and it has been
for awhile. I was wanting to get around the delay time by using an
Ok button to signal when the selection was what I wanted. I have
built a small test case that seems to want to work, but on the second
character input I get a 0x0005 (op code?) violation -not sure where
as I am not familiar with how to peruse that type of error. I will
zip up the three files (rex, rc and h) for the test and you can tell me
where I have made a stupid mistake !! (sending to your private addr)
Really hate to bother you on a weekend, but do appreciate your help.
Art
> Art,
>
> This is what the MSDN docs say about the default processing by the
> listbox of the WM_CHAR message:
>
> "Moves the selection to the first item that begins with the
> character the user typed. If the list box has the LBS_OWNERDRAW
> style, no action occurs.
>
> Multiple characters typed within a short interval are treated as a
> group, and the first item that begins with that series of
> characters is selected."
>
> Below is a very simple listbox that demonstrates the default
> incremental search. If I run it and type in A C T and hit enter, I
> get this back:
>
> User searched for and found: ActionCenter.dll
>
>
> So, it seems to work pretty good. The only thing I don't like is
> the delay time before it stops treating the letters as a group. If
> you type A C and delay a bit, when you type T it takes you to:
> t2embed.dll
>
> This would be a dialog to start with and use to implement your own
> incremental search:
>
> /* Simple Dialog listBoxSearch.rex */
>
> symbolMap = .table~new
> symbolMap[IDC_LB_FILEs] = 200
> --symbolMap[] =
> --symbolMap[] =
>
> .application~setDefaults('O', symbolMap, .false, 'Courier New', 10)
>
> dlg = .SimpleDialog~new
> if dlg~initCode = 0 then do
> if dlg~execute("SHOWTOP") == dlg~IDOK then do
> say 'User searched for and found:' dlg~searchAndFound end
> else do say 'User canceled' end end
>
> return 0
> -- End of entry point.
>
> ::requires "ooDialog.cls"
>
> ::class 'SimpleDialog' subclass UserDialog
>
> ::attribute searchAndFound get
> expose selectedText
> return selectedText
>
> ::method init
> expose selectedText
>
> forward class (super) continue
> title = "Directory Listing with Search"
> self~create(30, 30, 186, 124, title, "CENTER")
> selectedText = ''
>
> ::method defineDialog
>
> style = 'VSCROLL HSCROLL PARTIAL SORT NOTIFY'
> self~createListBox(IDC_LB_FILES, 10, 10, 166, 90, style)
> self~createPushButton(IDOK, 126, 105, 50, 14, 'DEFAUT', "Ok")
> self~createPushButton(IDCANCEL, 74, 105, 50, 14, ,"Push Me")
>
> ::method initDialog
> expose lb
>
> lb = self~newListBox(IDC_LB_FILES)
> attributes = "READWRITE READONLY HIDDEN SYSTEM DIRECTORY ARCHIVE"
> lb~addDirectory("C:\Windows\System32\*", attributes)
>
> ::method ok unguarded
> expose lb selectedText
>
> selectedText = lb~selected
> return self~ok:super
>
> ::method cancel unguarded
>
> msg = 'Haa - tricked you. Push Me is actually cancel' title =
> "You Have Just Been Canceled" ret = MessageDialog(msg, self~hwnd,
> title) return self~cancel:super
>
>
> On Sun, Jun 30, 2013 at 11:49 AM, Mark Miesfeld
> <miesf...@gmail.com> wrote:
>
>> Hi Art,
>>
>> I've never tried something like that, but this is how I would
>> start.
>>
>>
>> Set an exposed variable to the empty string. Connect the onChar
>> event to the listbox. When the event handler is invoked, append
>> the character to the exposed variable. Then use the find()
>> method using the exposed variable string as the textOrPrefix,
>> probably the current index as the startIndex, and exact as false.
>>
>
>> If you get a hit, move the selection to the returned index. Each
>> time a new character comes in, it is appended to the current
>> search string and find() is invoked again. I think that should
>> get you close, then you run it and see what doesn't work.
>>
>
>> You want to set up your onChar handler so that the character is
>> not passed on to the listbox. I'm hoping the docs are sufficient
>> for you to determine how to do that. I'm not being secretive, if
>> I remembered off of the top of my head I'd just tell you.
>>
>
>> One thing that thing I can think of that might take a little
>> thought is what to do if the find() does not produce a hit.
>>
>>
>> Also, you'll need to figure out when to set the search string
>> back to the empty string.
>>
>
>> Let me know if you are having problems. If I have a little time,
>> I'll probably play with it a bit.
>>
>>
>> The other thing is, the listbox seems to already have a search
>> function built in. You do realize that don't you? I suspect you
>> are asking because the built in procedure is not sufficient for
>> what you want. I don't have any example programs around that
>> have very many items in a listbox, but it seems to work somewhat.
>>
>
>> --
>> Mark Miesfeld
>>
>>
>> On Sun, Jun 30, 2013 at 10:33 AM, Art Heimsoth
>> <artst...@artheimsoth.com> wrote:
>
>
>>> I am trying to locate a string in a listbox by typing the
>>> characters, but
>>>
> I want the number of characters to be variable. For example, in
> looking for names in a listbox, I would like to start typing and
> for each character bring up the next matching string. I am using
> Find and I understand I can specify a multiple character string,
> but I would like for the listbox find to select the first item
> matching the first character, allow me to enter another character
> and have the find select the string that now matches both
> characters, repeating until the Enter key is pressed where the Ok
> button would then cause the currently selected string to be
> retrieved, but how would I approach this? How would I define an
> onChar event on the listbox to allow me to build the string to be
> passed to the find? Any suggestions as to approach appreciated.
>
>>> --
>>> Art Heimsoth - artst...@artheimsoth.com
>
>>>
>>> ----------------------------------------------------------------
>>> --------------
>>>
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
>>> _______________________________________________
>>>
> Oorexx-users mailing list
> Oorexx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
--
Art Heimsoth - artst...@artheimsoth.com
--
Art Heimsoth - artst...@artheimsoth.com
------------------------------------------------------------------------------ This SF.net email is sponsored by Windows:
Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev
_______________________________________________ Oorexx-users mailing list Oorexx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-users