Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some questions about drop-down lists with filter function
#5
seems when using the sort function of the dropdown list the selected item will be the original first item so
to fix sort the csv before then all will work
 
Code:
Copy      Help
_s=
;sw 1 Switch
;wi 2 b
;wi 1 a
;ps Powershell
;we howc
;we how
;fun c Process
;fun b Pro
;pr file
;co ac
;oc cc

ARRAY(str) aList=_s

IQmDropdown ddl; int inERS

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x8 0 0 184 16 "Autotext" "4"
;3 Edit 0x54030080 0x200 0 0 184 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""
str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
out e3
#sub DlgProc
function# hDlg message wParam lParam

__GdiHandle- t_hbrush
sel message
,case WM_INITDIALOG
,int- backcolor=0x955100
,int- textcolor=0xffffff
,t_hbrush=CreateSolidBrush(backcolor)
,__Font- f.CreateNew(hDlg "Consolas" 12 1)
,f.SetDialogFont(hDlg "3")
,case WM_DESTROY
,case WM_DRAWITEM
,DT_SCFC_on_WM_DRAWITEM hDlg wParam lParam
,case WM_COMMAND goto messages2
,case WM_CTLCOLOREDIT
,,if(lParam=id(3 hDlg))
,,,SetTextColor wParam textcolor
,,,SetBkColor wParam backcolor
,,,ret t_hbrush
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case EN_CHANGE<<16|3 sub.OnTextChanged lParam
,case EN_SETFOCUS<<16|3
,DT_ShowColorFocusControl hDlg
ret 1

#sub OnTextChanged v
function hEdit

if(inERS) ret
if(ddl) ddl.Close; ddl=0

str s.getwintext(hEdit)
if(!s.len) ret
int iSelected
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
x.Sort(3)
if(ShowDropdownList(x iSelected 0 0 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(iSelected+1 0)

inERS=1
EditReplaceSel hEdit 0 s 1|2|4
inERS=0
SendMessage(GetParent(hEdit) WM_COMMAND IDOK 0)


Messages In This Thread
RE: Some questions about drop-down lists with filter function - by Kevin - 12-14-2022, 03:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)