Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM Combo or Listbox with search

I like the way the "Index" tab in the Windows Help works. You type "G" and it jumps to "get". Then you type "L" (which would be "GL") and it jumps to "Globally unique identifiers"

The Windows XP Start->Run works like this too, as does the address bar in Explorer. The font-dropdown box in MS Word also does this.

I have a fairly long list of names, and I'd like to be able to quickly jump to the correct name by QM finding the first match, and then the next best match, and so on as I continue typing. I'd also like it to return that name's corresponding ID to my program. Any ideas how I could do this?


Send LB_SELECTSTRING to the list box when text box text changes.

Sample dialog (function dialog_incremental_search):

Copy      Help
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4"
str e3 lb4


if(!ShowDialog("dialog_incremental_search" &dialog_incremental_search &controls)) ret

;0 "" 0x10C80A44 0x100 0 0 223 135 "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 ListBox 0x54230101 0x200 2 18 96 90 ""
;DIALOG EDITOR: "" 0x2010703 "" ""

sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
sel wParam
,case EN_CHANGE<<16|3
,SendMessage(id(4 hDlg) LB_SELECTSTRING -1 _s.getwintext(lParam))
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
Thanks for the reply! It worked.

One more question: Can I watch for a Up or Down Arrow keypress when I'm typing in the text box, and then set the focus to the listbox?
Subclass the edit control, watch for WM_KEYDOWN message with wParam=VK_DOWN and VK_UP, and then act the listbox.

More info:

Forum Jump:

Users browsing this thread: 1 Guest(s)