I am intercepting the WM_CHAR message and the wParam of VK_TAB. Everything is going good and I can replace the tab key with as many spaces or characters that I want. The problem is that when the caret reaches the rightmost boundary of the rectangular shape of a rich edit, it won't advance anymore when I send the EM_REPLACESEL message to add some text to the current position in the Rich Edit. This is the code I've written in the Window Procedure of the Rich Edit:

  else if (Msg == WM_CHAR){
    if (wParam == VK_TAB){
      if (TabBuffer_Initialize() == true){
        SendMessage(hWnd, EM_REPLACESEL, (WPARAM)true, (unsigned int)TabBuffer);
        TabBuffer_Uninitialize();
      } /* if (TabBuffer_Initialize() ==true){ */
      return(0);
    } else /* if (wParam == VK_TAB){ */
      return(CallWindowProcA(PreviousRichEditWndProc, hWnd, Msg, wParam, lParam));   
  } /* else if (Msg == WM_CHAR){ */


The WM_CHAR is sent even when the caret doesn't advance anymore. Once I press the tab key as many times as it is required to get to the rightmost position of the current line in the Rich Edit, the code won't allow the caret to go to the next line. I don't think I have to send CR or LF to the text because if I add two spaces manually, it will work.

Could somebody tell me what is wrong with this code?
Posted on 2008-01-06 09:16:12 by XCHG