Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some questions about drop-down lists with filter function
#3
for #2 easiest solution is this
 
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

#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

ICsv x._create
x.AddRow1(0 "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 8 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(i+1 0)

inERS=1
EditReplaceSel hEdit 0 s 1|2|4
inERS=0

need two extra functions
Function DT_SCFC_on_WM_DRAWITEM
 
Code:
Copy      Help
function hDlg wParam lParam

;Call this from dialog procedure on WM_DRAWITEM.
;Makes the focus rectangle blue.

int color=0x00FF000 ;;green

if(wParam!999) ret
__GdiHandle-- t_brush=CreateSolidBrush(color)
DRAWITEMSTRUCT& d=+lParam
RECT r; GetClientRect d.hWndItem &r
FillRect d.hDC &r t_brush

Function DT_ShowColorFocusControl
Code:
Copy      Help
function hDlg

;Call this from dialog procedure whenever focused control changed.

int borderWidth=2

;create static control that will be the focus rectangle
int hr=id(999 hDlg 1)
if(!hr) hr=CreateControl(0 "Static" 0 SS_OWNERDRAW 0 0 0 0 hDlg 999)
ShowWindow hr 0

;get rectangle of focused control and move our focus rect control there
int hf=GetFocus; if(!hf) ret
RECT r; GetWindowRect hf &r; MapWindowPoints 0 hDlg +&r 2
MoveWindow hr r.left r.top r.right-r.left r.bottom-r.top 0

;make our focus rect control hollow, to look like a rectangle with 1 pixel border
OffsetRect &r -r.left -r.top
int r1=CreateRectRgnIndirect(&r)
__GdiHandle r2; InflateRect &r -borderWidth -borderWidth; r2=CreateRectRgnIndirect(&r)
CombineRgn r1 r1 r2 RGN_DIFF
SetWindowRgn hr r1 0

BringWindowToTop hr
ShowWindow hr SW_SHOW


Messages In This Thread
RE: Some questions about drop-down lists with filter function - by Kevin - 12-13-2022, 01:30 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)