Posts: 197
Threads: 60
Joined: Dec 2013
Hello,
Is this possible?
An example would be google's "instant search" that shows related search phrases as you type.
Thanks.
Posts: 12,071
Threads: 140
Joined: Dec 2002
Where it would be used? In a custom dialog? Possible. Need some programming.
Posts: 197
Threads: 60
Joined: Dec 2013
I think so. I have a list of text that I want to search-as-i-type.
Posts: 12,071
Threads: 140
Joined: Dec 2002
Function
dialog_search_as_you_type
;Run this macro. Type something from the list, eg o or r.
;Need QM 2.4.3.
str sList
sList=
;one
;two
;three
;four
ARRAY(str) aList=sList
IQmDropdown ddl
int inERS
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040303 "*" "" "" ""
str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc v
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case EN_CHANGE<<16|3 sub.OnTextChanged lParam
ret 1
#sub OnTextChanged v
function hEdit
if(inERS) ret
if(ddl) ddl.Close; ddl=0
str s.getwintext(hEdit)
if(!s.len) ret
ICsv x._create
x.AddRow1(0 "")
int i
for i 0 aList.len
,if(find(aList[i] s 0 1)<0) continue
,x.AddRow1(-1 aList[i])
if(!x.RowCount) ret
if(ShowDropdownList(x i 0 1 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(i+1 0)
inERS=1
EditReplaceSel hEdit 0 s 1
inERS=0
Posts: 1,006
Threads: 330
Joined: Mar 2007
Posts: 197
Threads: 60
Joined: Dec 2013
oh wow that was fast. I love you guys!
Posts: 726
Threads: 99
Joined: Mar 2018
04-15-2019, 11:06 PM
(This post was last modified: 04-15-2019, 11:08 PM by win.)
[b]@Gintaras[/b]
Hello, I modified the above code, I need to display the filtered results in the list box under the combo box, can achieve it? I very need this feature, thanks in advance.
The result of the following code, is that the items in the list box are always unchanged.
Macro
Filter in combo box
str sList
sList=
;one
;two
;three
;four
ARRAY(str) aList=sList
IQmDropdown ddl
int inERS
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 ComboBox 0x54230641 0x0 113 8 102 99 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""
str controls = "3 4"
str e3 cb4
cb4=sList
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
out
out e3
out cb4
#sub DlgProc v
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case EN_CHANGE<<16|3 sub.OnTextChanged lParam
,case CBN_EDITCHANGE<<16|4 sub.OnTextChanged lParam
ret 1
#sub OnTextChanged v
function hEdit
if(inERS) ret
if(ddl) ddl.Close; ddl=0
str s.getwintext(hEdit)
if(!s.len) ret
ICsv x._create
x.AddRow1(0 "")
int i
for i 0 aList.len
,if(find(aList[i] s 0 1)<0) continue
,x.AddRow1(-1 aList[i])
if(!x.RowCount) ret
if(ShowDropdownList(x i 0 1 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(i+1 0)
inERS=1
EditReplaceSel hEdit 0 s 1
inERS=0