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)
   
#2
This should be what your after
http://www.quickmacros.com/forum/showthr...4#pid27374
#3
@kevin
Thanks for your reminder, this feature is very good, it will be better to use it in the Add AutoText function.  Smile

http://www.quickmacros.com/forum/showthr...p?tid=6709

@kevin

I added a combo box, but the effect in the combo box is not the same as the effect in the edit box. For example, enter the letter r. See the image below.

In addition, I need to achieve an effect, when I enter a letter, if the word I need is in the first place, after I press the Enter key, the word, all appear in the edit box, for example, enter the letter a, enter After that, Autotext1 will appear in the edit box, please see the picture below.

This features can meet the needs of the link below  Smile

http://www.quickmacros.com/forum/showthr...3#pid33173


Macro Macro2
Code:
Copy      Help
;Run this macro. Type something from the list, eg o or r.
;Need QM 2.4.3.

str sList
;sList=
;;one
;;two
;;three
;;four

QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
sList=atn

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 92 ""
;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=atn
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

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 EN_CHANGE<<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


Attached Files Image(s)
   
#4
With the above features, this combo box becomes more powerful,

can be edited,   searched,   listable,   filtered,  Drag selection,  abbreviated automat input
Tongue
#5
for starters this line in wrong

case EN_CHANGE<<16|4 sub.OnTextChanged lParam
its a ComboBox not  an edit control
that line does nothing. The event never fires!

case CBN_EDITCHANGE<<16|4

but using this
    case CBN_EDITCHANGE<<16|4 sub.OnTextChanged lParam
the drop box will fire below the combobox.
Not sure why you want a combobox and then want to create another dropdown box Huh
#6
The list box below the combo box, I can directly double-click the item inside, sometimes it is very convenient to operate  Smile

How make search results appear in the list below the combo box?

My ultimate goal is to achieve three-level management of Autotext, as shown below

When I click the folder in the list in the first combo box, the file inside it will appear in the list in the second combo box. When I click on the file name, the items in the file appear in the list of the third combo box, Finally, when I press the OK button, It will automatically jump to the item(subfunction) of the file Smile

Macro AutoText Management
Code:
Copy      Help
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
str sList
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
sList=atn

ARRAY(str) aList=sList
IQmDropdown ddl
int inERS

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 338 182 "AutoText Management" "4"
;6 Static 0x54000000 0x0 37 4 48 13 "Folder"
;7 Static 0x54000000 0x0 148 4 48 13 "File"
;8 Static 0x54000000 0x0 259 4 48 13 "item"
;9 ComboBox 0x54230641 0x0 7 17 104 138 ""
;3 ComboBox 0x54230641 0x0 117 17 104 138 ""
;4 ComboBox 0x54230641 0x0 227 17 104 138 ""
;1 Button 0x54030001 0x4 213 162 48 14 "OK"
;2 Button 0x54030000 0x4 272 162 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "9 3 4"
str cb9 cb3 cb4
cb3=sList
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
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 CBN_EDITCHANGE<<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

It’s a bit strange, I can filter if I don’t set any events, please see the image below. Huh

It is very convenient to use the combo box with filtering function to achieve the above goals, but the programming difficulty is also the biggest.  Wink


Attached Files Image(s)
       
#7
I redesigned the interface for AutoText management. Please see the image below.

There are two ways to find an AutoText items.

The first method: enter the name in the search box at the top, it will be automatically filtered, and the filtered list will be displayed. After you find it, you can click the "Edit" or "Run" button.

The second method: Gradually find the item you are looking for through three levels of lists (folders, files and items). Once found, you can click the "Edit" or "Run" button.

In addition, it has some other small features, such as :
A. create folders, files, items
B. The edit box in the combo box can be filtered by entering letters

I have a limited level of programming now, I can't finish it. I hope someone can provide some suggestions, thank you very much. 
Heart

Macro AutoText Management2
Code:
Copy      Help
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi

;str sList
;sList=atn
;ARRAY(str) aList=sList

ARRAY(str) aList=atn
IQmDropdown ddl
int inERS

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 338 218 "AutoText Management" "4"
;11 Edit 0x54030080 0x200 127 9 120 13 ""
;9 ComboBox 0x54230641 0x0 7 49 104 138 ""
;3 ComboBox 0x54230641 0x0 117 49 104 138 ""
;4 ComboBox 0x54230641 0x0 227 49 104 138 ""
;6 Static 0x54000000 0x0 37 36 48 13 "Folder"
;7 Static 0x54000000 0x0 148 36 48 13 "File"
;8 Static 0x54000000 0x0 259 36 48 13 "item"
;10 Button 0x54032000 0x0 147 195 48 14 "Edit"
;5 Button 0x54032000 0x4 81 195 48 14 "Create"
;12 Static 0x54000000 0x4 71 11 50 12 "All items Search"
;1 Button 0x54030001 0x4 213 195 48 14 "Run"
;14 Static 0x54000010 0x20000 7 29 326 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "11 9 3 4"
str e11 cb9 cb3 cb4
cb3=atn
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
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|11 sub.OnTextChanged lParam
,;case CBN_EDITCHANGE<<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


Attached Files Image(s)
   


Forum Jump:


Users browsing this thread: 1 Guest(s)