Thread: CEdit::OnChar() won't work for derived class!

  1. #1
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001

    Question CEdit::OnChar() won't work for derived class!


    I'm writing an app that allows people to edit text data together in a single edit box over a network connection.
    On each keypress by the user in control over the edit, a message is sent telling them which char was pressed at which point the receiver's edit calls a CEdit::OnChar(ch, 0, 0); to simulate the keypress in his window.

    I am quite perplexed with the situation at hand for the reason that the code is quite simple and straightforward.

    In my OnChar(), CNetEdit::OnChar(...), I have a messagebox displaying what nChar was passed before my CEdit::OnChar(...) call and it is indeed what was sent from the client, but the call does seemingly nothing!
    When I type directly into the edit, the call works fine.

    I have tried other variants in the code, but to no avail. For example:
    void CNetEdit::OnChar(UINT ch) {
      OnKeyDown(ch, 0, 0);// call CNetEdit's messagemapped func
      OnChar(ch, 0, 0);// call CNetEdit's messagemapped func
      CEdit::OnKeyDown(ch, 0, 0);
      CEdit::OnChar(ch, 0, 0);
    Please tell me you have some type of hint as to what I could be doing wrong. Thanks much in advance.

    I have altered the public accessor function that calls the protected OnChar() to accept the nRepCnt and nFlags of the keypress, but there is still no change...

    Okay, I actually made it work. I kept trying to call my messagemapped OnChar() func which wasn't working, but using a PostMessage(WM_CHAR,...) did work.. I still don't understand what the problem was, but it is working.. If you know, please explain. Thanks.
    Last edited by LuckY; 02-28-2003 at 01:45 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Default class template problem
    By Elysia in forum C++ Programming
    Replies: 5
    Last Post: 07-11-2008, 08:44 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Font class, why won't it work?
    By fusikon in forum Game Programming
    Replies: 2
    Last Post: 02-09-2003, 09:07 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM