04-11-2019, 09:31 PM
Found in archive.qml
http://www.quickmacros.com/forum/showthr...p?tid=2852
Function Edit_AutoComplete
Function dlg_edit_autocomplete
Function dlg_combo_autocomplete
Function CB_AutoComplete
http://www.quickmacros.com/forum/showthr...p?tid=2852
Function Edit_AutoComplete
;/
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
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str qmg3x
if(!ShowDialog("" &dlg_edit_autocomplete &controls)) ret
;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 168 78 "0x0,0,0,0,0x0[]A,,,[]combo,,1,"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,str-- t_data
,t_data="one[]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
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str cb3
cb3="&one[]two[]three[]four[]five[]six[]seven[]eight[]nine"
if(!ShowDialog("dlg_combo_autocomplete" &dlg_combo_autocomplete &controls)) ret
;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 ComboBox 0x54230342 0x0 6 4 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010900 "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_EDITCHANGE<<16|3
,CB_AutoComplete lParam
,case IDOK
,case IDCANCEL
ret 1
;/
function hcb
;Automatically completes when you type in combo box.
;Call from dialog procedure, on CBN_EDITCHANGE.
;hcb - combo box handle (use lParam).
;EXAMPLE
,;case CBN_EDITCHANGE<<16|3
,;CB_AutoComplete lParam
ifk(B) ret
ifk(X) ret
str s ss; int i
s.getwintext(hcb)
if(s.len)
,i=CB_FindItem(hcb s)
,if(i>=0)
,,CB_GetItemText(hcb i ss)
,,if(ss.len>s.len)
,,,ss.setwintext(hcb)
,,,SendMessage(hcb CB_SETEDITSEL 0 ss.len<<16|s.len)