• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Subclassing (zero pts for now)

I really have three questions, but they all kinda go together, so I put them all here. I'll increase/split the points depending on who answers what and how well.

#1. Basic subclassing method. I know it involves Get/SetWindowLong, AddressOf, etc., but I can't find my copy of this. Nothing fancy (yet), no subclassing ocxs/dlls/etc., just the basic outline.

#2. What are some possible msgs/lparams(?)/uparams(?) that can be passed to the subclassing procedure? For instance, the message could be the window-resize message and the params would be the new size. I would like a good size list, but I'll spread out points to anyone who can give me a set (msg and BOTH params) that hasn't been posted by someone else and works.

#3. Is it not possible to subclass a window in another app? I have an old VB3 app that I've written and don't feel like converting, but (when I had the subclass routine) when I tried it, the SetWindowLong statement failed (returned zero) and the subclassing didn't work. If it is, any ideas where I went wrong? If not, any ideas how to do the same thing (hooking, maybe?)?

Thanks for any help!

KDivad Leahcim
  • 3
  • 2
1 Solution
Try reading the following Microsoft KB Articles:

HOWTO: Hook Into a Window's Messages Using AddressOf
HOWTO: Position a MsgBox Using a Windows Hook Procedure
HOWTO: Subclass a VB Form Using 16-Bit VB CDK Custom Control
HOWTO: Build a Windows Message Handler with AddressOf in VB

HOWTO: Subclass a UserControl

KDivadAuthor Commented:
You've answered number 1.
I've figured out some of number 2.
Number 3 still has me lost. The particular message I want to intercept for the VB3 app is the window resize event. Like I said, the subclassing failed and I don't know if hooking can be used to do this or how. I understand the very basics of hooking but not much more.
Also take a look here:

TN024: MFC-Defined Messages and Resources
Sending Messages
Your own window procedure

By the way, As for #3, I don't think it's possible to subclass another applications window.  I may be wrong, but I don't think so...


KDivadAuthor Commented:
I'm inclined to believe that you can't subclass a window outside your own app. I failed to get it to work and 3 other people (including you) have also said they don't think it's possible. Oh well, it was worth a shot. The only light in the tunnel is one line from the third article you posted: "Keep in mind that you aren’t the only programmer in the world who might be subclassing your window." This would lead one to believe that it is possible, but he(she?) apparently learned all this almost from scratch, so maybe not.

Thanks for the help!
Glad I could help! Thanks for the points...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now