Results 1 to 13 of 13

Thread: Subclassing a richtextbox

  1. #1

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Resolved Subclassing a richtextbox

    I'm using the SetWindowLong API to subclass a richtextbox. The WinProc function that I have is:
    VB Code:
    1. Public Function WindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
    2.    ' Filter for messages of interest, but
    3.    ' allow default processing for most.
    4.    'Select Case msg
    5.          
    6.       'Case Else
    7.          ' Default processing...
    8.          WindowProc = DefWindowProc(Form1.txtDocument.hwnd, msg, wp, lp)
    9.    'End Select
    10. End Function
    As you can see the program, for now, is just there as another layer, not doing anything with the messages. I know this function is being called because of some debugging I did. My problem is that the richtextbox isn't getting of the messages, so it is not repainting, accepting focus, etc.
    Last edited by Disiance; Feb 8th, 2005 at 09:41 PM.
    "I don't want to live alone until I'm married" - M.M.R.P

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Subclassing a richtextbox

    WindowProc = DefWindowProc(Form1.txtDocument.hwnd, msg, wp, lp)
    Shouldn't that be
    VB Code:
    1. WindowProc = CallWindowProc(OrigWndProc, hwnd, uMsg, wParam, lParam)
    Where OrigWndProc is the value returned by SetWindowLongPtr?

    ...

  3. #3

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    Nope, according to MSDN:
    Quote Originally Posted by MSDN
    hWnd
    [in] Handle to the window procedure that received the message.
    http://msdn.microsoft.com/library/de...windowproc.asp
    "I don't want to live alone until I'm married" - M.M.R.P

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Subclassing a richtextbox

    Nope, according to MSDN... blah, blah, blah
    OK, You should mark your post as resolved if you already have all the answers.

    ...

  5. #5

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    Well its not working, like I said the richtextbox stops responding.
    "I don't want to live alone until I'm married" - M.M.R.P

  6. #6
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Subclassing a richtextbox

    Well its not working...
    But according to you, you're doing everything right.
    So, how could it not be working?
    ...

  7. #7

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    that is my question.
    "I don't want to live alone until I'm married" - M.M.R.P

  8. #8
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Subclassing a richtextbox

    I guess subtlety isn't going to work here.
    I tried to help you in my first post, but you argued with me and said you new better.

    Second hint, search the forums for your answer.

    -bye bye

  9. #9

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    I know its a problem with the RTB because I when I change the hWnd to the Form's hWnd it works fine, the problem only occurs when I subclass the RichTextBox. I've searched the forumn and cannot find an answer to this problem.
    "I don't want to live alone until I'm married" - M.M.R.P

  10. #10

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    Okay, finally got it thanks to an MSDN article I found:
    http://msdn.microsoft.com/library/de...Procedures.asp
    Turns out you have to use a combination of the DefWindowProc function and the CallWindowProc function.
    "I don't want to live alone until I'm married" - M.M.R.P

  11. #11
    Hyperactive Member
    Join Date
    Nov 2003
    Location
    In Front of my computer...
    Posts
    367

    Re: Subclassing a richtextbox

    just replying to tell you moeur was right..

    WndProc = CallWindowProc(pOldWindPoc, hWnd, uMsg, wParam, lParam)

    pOldWindPoc = SetWindowLong(Form1.txtDocument.hwnd, GWL_WNDPROC, AddressOf WndProc)

    that would work and 100% sure...
    but glad you got it working
    Born to help others
    (If I've been helpful then please rate my post. Thanks)

    call me EJ or be slapped!

  12. #12
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Re: Subclassing a richtextbox

    Bet your glad you searched to find that MSDN article when the answer was right in front of you...

  13. #13

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Subclassing a richtextbox

    yah well, the problem was I had misread moeur's post and thought he was telling me to use the function I was but passing a different variable to it, I didn't see that he suggested the use of a different function
    "I don't want to live alone until I'm married" - M.M.R.P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width