Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Edit box displays a list of identical letters
#1
Hello, the code below is a bit of a problem. When I type the letter o, the whole word onekey is displayed, Please see the picture below.

In addition, I need to achieve an effect, because the first two letters are the same for these three words (one[]only[]onekey[]).

So, when I type the letter on, the edit box will become a drop-down list that shows the three words. I can use the arrow keys to make a selection. This feature is very practical, Can this be achieved?

Any suggestions are welcome, thanks in advance Smile


Function Edit_AutoComplete
Code:
Copy      Help
/
function hEdit $items

;Automatically completes when you type in edit control.
;Call from dialog procedure, on EN_CHANGE. For grid control (edit or combo cell), call on GRID.LVN_QG_CHANGE.

;hEdit - edit control handle.
;items - list of items.

;EXAMPLE
,;case EN_CHANGE<<16|3
,;Edit_AutoComplete lParam "one[]two[]three"


ifk(B) ret
ifk(X) ret

str s1 s2

s1.getwintext(hEdit)
if s1.len
,foreach s2 items
,,if(s2.begi(s1) and s1.len<s2.len)
,,,s2.setwintext(hEdit)
,,,SendMessage hEdit EM_SETSEL s1.len s2.len
,,,break

Function Edit_AutoComplete_dlg
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 220 132 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Edit 0x54030080 0x200 2 2 96 14 ""
;4 QM_Grid 0x56031041 0x0 2 18 204 96 "0x0,0,0,0x0,0x0[]Edit,,,[]Combo,,1,"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,str-- t_data
,t_data="one[]only[]onekey[]two[]three[]four[]five[]six[]seven[]eight[]nine"
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case EN_CHANGE<<16|3
,Edit_AutoComplete lParam t_data
,case IDOK
,case IDCANCEL
ret 1

;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4
,GRID.QM_NMLVDATA* cd=+nh
,sel nh.code
,,case GRID.LVN_QG_COMBOFILL ;;when user clicks combo box arrow
,,;out "combo fill: item=%i subitem=%i" cd.item cd.subitem
,,if cd.subitem=1
,,,TO_CBFill cd.hcb t_data
,,
,,case GRID.LVN_QG_CHANGE ;;when user changes grid content
,,;out "text changed: item=%i, subitem=%i, text=%s, newtext=%s" cd.item cd.subitem cd.txt _s.getwintext(cd.hctrl)
,,if cd.hctrl and cd.subitem=1
,,,Edit_AutoComplete cd.hctrl t_data


Attached Files Image(s)
   


Messages In This Thread
Edit box displays a list of identical letters - by win - 04-13-2019, 10:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)