API and Rich edit control

This is a discussion on API and Rich edit control within the Windows Programming forums, part of the Platform Specific Boards category; I wrote an app for a friend with MFC, but it won't run on his computer for some unknown reason. ...

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

    API and Rich edit control

    I wrote an app for a friend with MFC, but it won't run on his computer for some unknown reason. Anyway, I'm rewriting it with API, but I am not an API programmer, so I need some assistance.

    I have a rich edit control and I want to handle the WM_CHAR and WM_KEYDOWN messages (among others) and know that I need to create a separate procedure to handle the richedit's messages, but I don't know how to do that... I've created it with CreateWindowEx(), but how do I tell the app where to send its messages?

    Thanks yo.

  2. #2
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Something along the lines of SetWindowLong() with the GWL_WNDPROC flag. Pass in a function pointer to your new procedure to redirect the control's messages.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    >>I've created it with CreateWindowEx(), but how do I tell the app where to send its messages?

    The msgs are sent to the parents or owners HWND as supplied. The resouce ID is cast as the HMENU param.

    change on fly
    Code:
    //get old WNDPROC to send msg's  we are not interested in back to
        lpfnDefOldProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
    //set to the new WNDPROC
        SetWindowLong(hWnd, GWL_WNDPROC, (LONG)NewWndProc);
    Last edited by novacain; 05-01-2003 at 10:06 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rich Edit: Visual Style
    By underline_bruce in forum Windows Programming
    Replies: 2
    Last Post: 08-15-2007, 06:25 PM
  2. newbie to rich edit, cant get it to work
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 03-24-2004, 10:54 PM
  3. rich edit with winapi
    By Devil Panther in forum Windows Programming
    Replies: 2
    Last Post: 01-30-2003, 02:25 PM
  4. colorful rich text edit boxes
    By master5001 in forum Windows Programming
    Replies: 0
    Last Post: 11-26-2001, 11:52 AM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 03:12 AM

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