Subclassing a richtextbox
I'm using the SetWindowLong API to subclass a richtextbox. The WinProc function that I have is:
VB Code:
Public Function WindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
' Filter for messages of interest, but
' allow default processing for most.
'Select Case msg
'Case Else
' Default processing...
WindowProc = DefWindowProc(Form1.txtDocument.hwnd, msg, wp, lp)
'End Select
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.
Re: Subclassing a richtextbox
Quote:
WindowProc = DefWindowProc(Form1.txtDocument.hwnd, msg, wp, lp)
Shouldn't that be
VB Code:
WindowProc = CallWindowProc(OrigWndProc, hwnd, uMsg, wParam, lParam)
Where OrigWndProc is the value returned by SetWindowLongPtr?
...
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
Re: Subclassing a richtextbox
Quote:
Nope, according to MSDN... blah, blah, blah
OK, You should mark your post as resolved if you already have all the answers.
...
Re: Subclassing a richtextbox
Well its not working, like I said the richtextbox stops responding.
Re: Subclassing a richtextbox
Quote:
Well its not working...
But according to you, you're doing everything right.
So, how could it not be working?
...
Re: Subclassing a richtextbox
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
:wave:
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.
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.
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 :)
Re: Subclassing a richtextbox
Bet your glad you searched to find that MSDN article when the answer was right in front of you...
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 :blush: