Hello to all,
The following post is from my ever ending battle to learn the text handling side of windows:
My question is, how do I simulate the VK_LEFT key from the soft end to get the same result from the keyboard. I've tried everything I could think of to get the caret to backup one space after the subclass function adds another character (ie "" and ()).
Passing the WM_KEYDOWN message does cause the caret to backup but the trailing character is highlighted.
Using the get/set caret functions also move the caret back but on the next char key down, the caret jumps over the inserted character inserted by the subclass function. Like it moved but the edit control didn't know about it????????
I've read till I'm blue in the face. HELP!!!
Cheers,
Cecil
The following post is from my ever ending battle to learn the text handling side of windows:
Code:
' ----------------------------------------------------------------------------- FUNCTION editSubclassProc(BYVAL hEdit AS LONG, _ BYVAL wMsg AS LONG, _ BYVAL wParam AS LONG, _ BYVAL lParam AS LONG) AS LONG LOCAL fPassThru AS LONG FUNCTION = %FALSE 'Initialize function to False SELECT CASE wMsg CASE %WM_LBUTTONUP, %WM_KEYUP updCaretPos2Sbar hEdit, ghStatus, 0, 0 CASE %WM_CHAR '/* Pass the character message to default edit control procedure */ CallWindowProc glpfnDefEditProc, hEdit, wMsg, wParam, lParam SELECT CASE wParam CASE 34 'User typed a ", send matching " IF ISFALSE fPassThru THEN fPassThru = %TRUE 'Prevent closed loop CallWindowProc glpfnDefEditProc, hEdit, wMsg, wParam, lParam '/* Move the caret back one space */ 'CallWindowProc glpfnDefEditProc, hEdit, %WM_KEYDOWN, %VK_LEFT, 0 END IF CASE 40 'User typed a (, send matching ) CallWindowProc glpfnDefEditProc, hEdit, wMsg, 41, lParam 'CallWindowProc glpfnDefEditProc, hEdit, %WM_KEYDOWN, %VK_LEFT, 0 'PostMessage hEdit, %WM_KEYDOWN, %VK_LEFT, 0 'SendMessage GetParent(hEdit), %WM_KEYDOWN, 0, 0 END SELECT EXIT FUNCTION CASE %WM_CONTEXTMENU 'EXIT FUNCTION CASE %WM_DESTROY SetWindowLong hEdit, %GWL_WNDPROC, glpfnDefEditProc 'Restore procedure END SELECT FUNCTION = CallWindowProc(glpfnDefEditProc, hEdit, wMsg, wParam, lParam) END FUNCTION 'editSubclassProc ' -----------------------------------------------------------------------------
Passing the WM_KEYDOWN message does cause the caret to backup but the trailing character is highlighted.
Using the get/set caret functions also move the caret back but on the next char key down, the caret jumps over the inserted character inserted by the subclass function. Like it moved but the edit control didn't know about it????????
I've read till I'm blue in the face. HELP!!!
Cheers,
Cecil
Comment