1 Attachment(s)
A new (and better?) way to Subclass in VB 6!
*** CODE ATTACHED TO THIS POST ***
Hi, I just figured out what may be a really great way to
Subclass in VB 6. Here are the some of the features of this 'alpha'
product.
* Every handle you subclass gets a UNIQUE WindowProc ().
By 'unique' I mean the actual binary code for every
WindowProc is within it's own dynamically allocated chunk
of memory.
* Pressing the 'Stop' button does not crash the IDE. In fact
you can use breakpoints, step through code, and basically
perform all normal debugging operations.
* The implementation is an event-driven class. You can
respond before and after a window handle is subclassed
and before and after a WindowProc () is processed. If you
happen to respond before then you may also optinally
change the data before it reaches the original WindowProc ()
OR you may simply cancel the original WindowProc () (of
course meaning that you are handling the message 100%
on your own).
The attached ZIP file contains the class' code and a demo
application (code of course). I apologize for the lack of comments,
and the occasional un-used function... but this is hot off the grill.
To install and run everything:
* Unzip the attached .zip file to a location of your choosing.
* Compile \<Zip Location>\ldsClasser\ldsClasser.vbp (this is
the actual subclasser). A DLL will now exist (and the
compilation should have registered it). Note, when you first
open up the project you will get (an expected) error
message 'Unable to set version compatible component...'.
You can safely igore this because I had the project set to
binary compatibility in my environment.
* Compile \<Zip Location>\MITestApp\MultiTestAppProject.vbp
(this is the demo program). Note, you will need to change
the reference to the location of the newly compiled DLL or
you will get a missing-reference compilation error.
* Execute MultiTestAppProject.exe
My intention (aside from sharing this 'hopefully' new discovery)
is to get feedback from all you VB Subclassing maniacs out there...
whether you like it, hate it, think it needs to work differently,
think it's dangerous... (you get the point).
Thanks,
-CC
Crunchy Cat, great... great... great...
you did it :)
i was out of the country for five days, i didn't forgot this subject, but i didn't get time to browse the net as well:)
it works with me perfectly (windows XP), i will test it later on Windows 2000 advance server, and win 98
thanks man :)
Final Build (code in next post)
And the changes have been made. Consider this an official beta
(minus a few functionalities I am reserving for myself :)).
The attached ZIP file contains the source code for both the
sub classer (ldsClasser) and a demo application (MultiTestApp).
TO INSTALL AND RUN EVERYTHING:
* Unzip the attached .zip file to a location of your choosing.
* Compile \<Zip Location>\ldsClasser\ldsClasser.vbp (this is
the actual subclasser). A DLL will now exist (and the
compilation should have registered it).
* Compile \<Zip Location>\MITestApp\MultiTestAppProject.vbp
(this is the demo program). Note, you may need to change
the reference to the location of the newly compiled DLL.
* Execute MultiTestAppProject.exe
TO USE THE SUBCLASSER IN YOUR OWN PROJECTS:
* Make sure that 'ldsClasser' is compiled.
* Make a reference to the compiled DLL in your project.
* Create an instance of the 'subClasser' object.
* Subclass away!
IMPORTANT NOTE: Always use 'ldsClasser' as an external DLL.
FEATURES OF THIS BETA:
* Same great features as before except Thunked 'WindowProc ()'s
are no longer used as they are no longer needed.
* The DLL can now be compiled with any optimization option.
Have fun folks!