|
-
Feb 7th, 2005, 09:15 PM
#1
Thread Starter
Hyperactive Member
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.
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
-
Feb 7th, 2005, 10:40 PM
#2
Re: Subclassing a richtextbox
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?
...
-
Feb 7th, 2005, 11:22 PM
#3
Thread Starter
Hyperactive Member
Re: Subclassing a richtextbox
Nope, according to MSDN:
 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
-
Feb 8th, 2005, 12:47 AM
#4
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.
...
-
Feb 8th, 2005, 10:44 AM
#5
Thread Starter
Hyperactive Member
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
-
Feb 8th, 2005, 11:19 AM
#6
Re: Subclassing a richtextbox
But according to you, you're doing everything right.
So, how could it not be working?
...
-
Feb 8th, 2005, 12:19 PM
#7
Thread Starter
Hyperactive Member
Re: Subclassing a richtextbox
"I don't want to live alone until I'm married" - M.M.R.P
-
Feb 8th, 2005, 12:25 PM
#8
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
-
Feb 8th, 2005, 12:48 PM
#9
Thread Starter
Hyperactive Member
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
-
Feb 8th, 2005, 09:40 PM
#10
Thread Starter
Hyperactive Member
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
-
Feb 8th, 2005, 11:04 PM
#11
Hyperactive Member
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! 
-
Feb 9th, 2005, 09:25 PM
#12
Lively Member
Re: Subclassing a richtextbox
Bet your glad you searched to find that MSDN article when the answer was right in front of you...
-
Feb 9th, 2005, 10:17 PM
#13
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|