Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking for a Dialog Example with Interactive List Filtering
#10
Thanks, Gintaras.
EM_GETSEL worked well.
Cheers,
John

Function listDialogEditSubclassProc
Code:
Copy      Help
;/
function# hWnd message wParam lParam

sel message
,case WM_DESTROY
,case [WM_PAINT, WM_GETTEXTLENGTH, WM_GETTEXT];; These messages happen lots
,case WM_GETDLGCODE ;; Happens twice per letter keypress
,case WM_SYSKEYDOWN ;; Happens repeatedly while Alt key down
,case [WM_KEYUP]; ret ;; Ignore keyup messages
,case [WM_KEYDOWN]
,int he=id(3 GetParent(hWnd))
,int hlb=id(4 GetParent(hWnd))
,;out "wParam=%i" wParam
,sel wParam ;;virtual key code
,,
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,;relay these keys to the listbox and not to the edit box
,,;out "%s: %i %i %i" fnName wParam=VK_UP LB_SelectedItem(hlb) LB_GetCount(hlb)
,,if wParam = VK_UP and LB_SelectedItem(hlb) = -1
,,,;If the up arrow is pressed and nothing is highlighted, then highlight the last entry
,,,LB_SelectItem hlb LB_GetCount(hlb)-1
,,else
,,,SendMessage hlb message wParam lParam
,,ret
,,
,,case [VK_INSERT,VK_RIGHT]
,,int cursorPos; SendMessage(he EM_GETSEL 0 &cursorPos)
,,str sEdit.getwintext(he)
,,if cursorPos <> len(sEdit)
,,,goto passMessageUp ;; Only replace edit text when cursor is at end of edit field
,,if(LB_SelectedItem(hlb) = -1); ret ;; Exit if no list item selected
,,; Copy current list value to text entry field
,,str s
,,LB_SelectedItem(hlb s) ;; Set edit box to selected item text
,,s.setwintext(he)
,,SendMessage he message VK_END lParam ;; Move cursor to end of new entry field
,,ret

,case WM_CHAR ;; Standard letter
,;out "WM_CHAR %i %c" wParam wParam
,;sel wParam ;;virtual key code
,,;case ['a']
,,;ret
,case WM_SYSKEYUP ;; Fires when Alt-letter keyup (but alt still held down)
,hlb=id(4 GetParent(hWnd))
,; Select one of the list items
,if(wParam>='A' && wParam<='Z')
,,int ind = wParam - 'A'
,,LB_SelectItem hlb ind
,,ret
,case else ;; for sel message
,int- cxx; cxx+1
,;out "%s uncaught message %i: x%X(%i) %i %i %i" fnName cxx message message wParam lParam hWnd

;passMessageUp
int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)