06-09-2009, 09:12 AM
I've made a bit of progress with my selection dialog.
TheVig: the MyEditSubclassProc SubclassWindow function inserts the select listbox line when the insert key is pressed.
Gintaras:
1. When a key I want to use with the listbox is detected in the MyEditSubclassProc function, can I "eat" the key so that the parent "listDialog" function does not receive it?
2. Is there some way to detect the typing cursor position in the edit field?
I would like to be able to use the right-arrow key to insert the currently selected listbox item, but only when the cursor is at the end of the edit field.
Thanks,
John
Function MyEditSubclassProc
TheVig: the MyEditSubclassProc SubclassWindow function inserts the select listbox line when the insert key is pressed.
Gintaras:
1. When a key I want to use with the listbox is detected in the MyEditSubclassProc function, can I "eat" the key so that the parent "listDialog" function does not receive it?
2. Is there some way to detect the typing cursor position in the edit field?
I would like to be able to use the right-arrow key to insert the currently selected listbox item, but only when the cursor is at the end of the edit field.
Thanks,
John
Function MyEditSubclassProc
;/
function# hWnd message wParam lParam
;__OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,case [WM_KEYDOWN] ;; ,WM_KEYUP
,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]
,,; Copy current list value to text entry field
,,str sEdit.getwintext(he)
,,out "right: %s" sEdit
,,str s
,,LB_SelectedItem(hlb s) ;; Set edit box to selected item text
,,;; Use LB_GetItemText
,,s.setwintext(he)
,,SendMessage he message VK_END lParam ;; Move cursor to end of new entry field
,,ret
,,;case else
,,;SendMessage hlb message wParam lParam
,,;ret
,; Select one of the list items
,if(wParam>='0' && wParam<='9')
,,int ind=wParam-'0'
,,LB_SelectItem hlb ind
int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)