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

This is a discussion on CEdit::OnChar() won't work for derived class! within the Windows Programming forums, part of the Platform Specific Boards category; Yo, I'm writing an app that allows people to edit text data together in a single edit box over a ...

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

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

    Yo,

    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:
    Code:
    void CNetEdit::OnChar(UINT ch) {
      OnKeyDown(ch, 0, 0);// call CNetEdit's messagemapped func
    //or
      OnChar(ch, 0, 0);// call CNetEdit's messagemapped func
    //or
      CEdit::OnKeyDown(ch, 0, 0);
    //or
      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.

    [EDIT]
    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...

    [EDIT]
    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, 09:44 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03: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
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21