Mofdify Input dropdownlist

61 views
Skip to first unread message

Jack Konings

unread,
Feb 24, 2022, 5:40:13 AMFeb 24
to
Hi,

On a window I've got a combobox as (sorted) dropdownlist. The box is filled with items which all have the same format like "R-"+9999 (like 'R-1234'). The list is used to select more detailed data.
Currently the user punches in "R-" followed by the number. In doing this the combobox displays the item which best fits the input.
Since the format is always the same punching in the "R-" is inefficient. It would be more convenient if the user just has to punch in the number and the best "R-9999" match would be shown.

I tried to get this behavior by defining a keyup event, "catch" the numbers and add "R-' to them. This didn't work well and i'm starting to doubt keyup is the right way to do this.

Can someone give me a hint as how to make the desired behavior?
TIA.

dlzc

unread,
Feb 24, 2022, 9:49:29 AMFeb 24
to
Dear Jack Konings:

On Thursday, February 24, 2022 at 3:40:13 AM UTC-7, Jack Konings wrote:
> Hi,
>
> On a window I've got a combobox as (sorted) dropdownlist. The box is
> filled with items which all have the same format like "R-"+9999 (like 'R-1234').
> The list is used to select more detailed data. Currently the user punches in
> "R-" followed by the number. In doing this the combobox displays the item
> which best fits the input. Since the format is always the same punching in
> the "R-" is inefficient.

The hacker solution: Push "R-" into the keyboard buffer, before entering the dialog. So you've entered it for them.

> It would be more convenient if the user just has to punch in the number
> and the best "R-9999" match would be shown.

Don't include the "R-" in the list you show them. "Doctor, it hurts when I do this!" Probably ignore "R" and "-" when they do press them, since you've trained some of them to type it. Might even say on screen "Enter the R-[number] you want more information on?"

David A. Smith

JohnMartens

unread,
Feb 24, 2022, 9:54:00 AMFeb 24
to
Why not use an SLE ?

Did you check on ListBoxSelect method ?

METHOD ListBoxSelect(oControlEvent) CLASS frmMyWindow
SUPER:ListBoxSelect(oControlEvent)
*
IF oControlEvent:Control:NameSym == #MYCOMBO


John


Op 24-2-2022 om 11:40 schreef Jack Konings:

Jack Konings

unread,
Feb 24, 2022, 10:03:46 AMFeb 24
to

> The hacker solution: Push "R-" into the keyboard buffer, before entering the dialog. So you've entered it for them.

And how would i do that?

Jack Konings

unread,
Feb 24, 2022, 10:07:52 AMFeb 24
to

> Why not use an SLE ?

Because I want the user to have the possibility to select the item with mouse (and see all the items).

> Did you check on ListBoxSelect method ?

Yes, but i fail to see how that would solve my issue.

Karl-Heinz

unread,
Feb 24, 2022, 12:56:19 PMFeb 24
to
Hi Jack

some month ago i posted a sleInputTimer class in the X#-Forum. With some
small modifications the code seems to work with a DROPDOWNLIST Combo too. To
see what's going on, i added some console output to the attached
cmbTimerSearch class. Just inherit your comboBox from cmbTimerSearch and
give it a try.

What the CB_SELECTSTRING msg does is described here:

https://docs.microsoft.com/en-us/windows/win32/controls/cb-selectstring

regards
Karl-Heinz

CLASS cmbTimerSearch INHERIT ComboBox
PROTECT _lTimerActive AS LOGIC
PROTECT _nInterval := 400 AS DWORD
PROTECT _cSearch AS STRING

METHOD Destroy() CLASS cmbTimerSearch

SELF:StopTimer()

SUPER:Destroy()

RETURN NIL

METHOD Dispatch ( oEv ) CLASS cmbTimerSearch
LOCAL oEvent AS Event


oEvent := oEv


DO CASE

CASE oEvent:message == WM_CHAR

_cSearch += CHR (oEvent:wParam )


CASE oEvent:message == WM_KEYUP

SELF:StartTimer()


CASE oEvent:message == WM_KEYDOWN

SELF:StopTimer()


CASE oEvent:message == WM_KILLFOCUS

SELF:StopTimer()


CASE oEvent:message == WM_TIMER


IF ! Empty ( _cSearch )

SELF:StopTimer()

? "Search for:" , _cSearch := "R-" + _cSearch

? SendMessage( SELF:Handle() , CB_SELECTSTRING , DWORD (
_CAST , -1 ) , LONG (_CAST, String2Psz ( _cSearch ) ) )

_cSearch := ""

ENDIF


ENDCASE


RETURN SUPER:Dispatch ( oEvent )


METHOD init (oOwner, nID, oPoint, oDimension, kComboType, kStyle ) CLASS
cmbTimerSearch

SUPER:init (oOwner, nID, oPoint, oDimension, kComboType, kStyle )

RETURN SELF

METHOD SetTimerInterval ( n ) CLASS cmbTimerSearch

_nInterval := n

RETURN SELF

METHOD StartTimer() CLASS cmbTimerSearch


IF ! _lTimerActive

IF SetTimer(SELF:Handle(), 4711 , _nInterval , NULL_PTR) == 4711

_lTimerActive := TRUE

ENDIF

ENDIF

RETURN _lTimerActive

METHOD StopTimer() CLASS cmbTimerSearch


IF _lTimerActive

IF KillTimer ( SELF:Handle() , 4711 )

_lTimerActive := FALSE

ENDIF

ENDIF

RETURN ! _lTimerActive

dlzc

unread,
Feb 24, 2022, 3:20:11 PMFeb 24
to
On Thursday, February 24, 2022 at 8:03:46 AM UTC-7, Jack Konings wrote:
> > The hacker solution: Push "R-" into the keyboard buffer, before entering the dialog. So you've entered it for them.
> And how would i do that?

Outside VO, but you probably have these WINAPI functions available:
https://stackoverflow.com/questions/10787949/insert-into-windows-keyboard-buffer

David A. Smith

Jack Konings

unread,
Feb 25, 2022, 10:49:53 AMFeb 25
to
> cmbTimerSearch class. Just inherit your comboBox from cmbTimerSearch and
> give it a try.

Ah, this gives me a push in the right direction. Thanks, I will give it a try.

Jack Konings

unread,
Feb 25, 2022, 10:51:06 AMFeb 25
to
> Outside VO, but you probably have these WINAPI functions available:
> https://stackoverflow.com/questions/10787949/insert-into-windows-keyboard-buffer

That's a little bit over my paygrade........
I'll give the sample of Karl-Heinz a go.

dlzc

unread,
Feb 25, 2022, 1:33:26 PMFeb 25
to
Dear Jack Konings:
OK. Don't you initialize the search string you have the customer type in to navigate that list? Can't you set it to "R-" before calling the display routine? I don't do VO, but we have stuff like this in xHarbour...

David A. Smith
Reply all
Reply to author
Forward
0 new messages