I've created a small text editor using richedit and i've been tryin to get the tab key to work properly in it.. so far i've done this - subclassed it,processed keyup messages checked if it was tab..

RichEditProc PROC hWnd:DWORD, wmsg, wparam, lparam
      .if wmsg == WM_KEYUP
      .if wparam==VK_TAB
            jmp tab
      .endif
      .endif
            jmp done
tab:
      invoke SendMessage, hwndRichEdit, WM_KEYDOWN, VK_RETURN,0
done:
      invoke CallWindowProc, lpRichEdit, hWnd, wmsg, wparam, lparam
ret
RichEditProc ENDP

Now when i press tab, it works and it moves to the next line.. But it works only once, it does not go beyond the second line.. Can someone tell me what i'm doin wrong here..??

One more thing, could u tell me how to send a VK_TAB in the sendmessage, if i use this
invoke SendMessage, hwndRichEdit, WM_KEYDOWN, VK_TAB,0, there is no response.. thats y i'm using VK_RETURN to check...

Thanx in advance
Posted on 2005-11-21 09:23:12 by lone_samurai5
The easiest way I have found to get the TAB key to respond as expected in a normal
window (not dialog window) is to process the isDialogMessage in your message loop.

Example:

.while TRUE
  invoke GetMessage,addr msg,NULL,0,0
  .break .if (!eax)
  invoke IsDialogMessage,hDialog,addr msg
  .if    eax == FALSE
      invoke TranslateMessage,addr msg
      invoke DispatchMessage,addr msg
  .endif
.endw
Posted on 2005-11-21 09:40:57 by anon
lone_samurai5,

Try sending a:

WM_KEYUP, VK_RETURN

to match the:

WM_KEYDOWN, VK_RETURN

hth,

farrier
Posted on 2005-11-21 09:43:31 by farrier
farrier,

I did what u said and it had no effect.. its still the same.. no matter where i press the tab key from it always returns to the 2nd line and it stays there.. any other suggestions??  :sad:
Posted on 2005-11-21 09:48:00 by lone_samurai5
lone_samurai5,

At your tab: label try the following:

invoke	keybd_event, VK_RETURN, NULL, NULL, NULL                   ;Press key
invoke Sleep, 200
invoke keybd_event, VK_RETURN, NULL, KEYEVENTF_KEYUP, NULL        ;Release key


You may not need the Sleep, but sometimes I have.  You only have to make sure the Edit window has the keyboard focus.

hth,

farrier
Posted on 2005-11-21 11:10:31 by farrier
Still Doesn't work farrier, i just noticed that when i press ctrl+tab it moves a tab space and goes to the next line properly,  :shock:
Posted on 2005-11-21 12:00:40 by lone_samurai5
Trust me, I've been down the road you are on. It's very difficult to make
the TAB key work properly by subclassing. Try disabling your subclass and
add the three lines to your window message handler from my post above.
Posted on 2005-11-21 12:12:59 by anon
I'm using a dialog window, besides the subclassing works, there's some problems with the sendmessage, i used keybd_event but it keeps moving if i press tab once..ie it doesn't stop after 1 tab, here's the code..

invoke keybd_event,VK_CONTROL,9dh,0 , 0
invoke keybd_event,9,97h,0 , 0
invoke keybd_event,9,97h, KEYEVENTF_KEYUP,0
invoke keybd_event,VK_CONTROL,9dh,KEYEVENTF_KEYUP,0
Posted on 2005-11-21 23:22:15 by lone_samurai5