Subclassing

John
02-28-2002, 08:34 PM
Attached is a little program which was written as an introduction for myself and others to subclassing. As an added bonus it will show you how in-accurate the intrinsic timer control in VB really is.

Here is the story:
After writing the simple subclassing app I decided to place a timer on the form and keep track of the time that the subclassing was going on. After doing this I decided to keep a count of the messages being displayed in the text box. Here is where I noticed how bad the problem can get with the Intrinsic Timer, while moving the form around it seems to miss firing when it should:-\. To keep track of the actual time I deided to use GetTickCount in the new window procedure and presto, it keeps much more accurate although not perfect time. It is really quite interesting. Here is what it shows:

- Displays some of the messages it recieves
- Keeps track of the number of messages displayed
- Keeps track of the total number of messages that came through
- Uses a timer control and shows the in-accuracy of it
- Uses GetTickCount to get a better estimate of time
- Shows how many messages per second came through

Check it out, and let me know what you think.

Happy Coding,
Orbity

Volte
03-01-2002, 07:18 AM
Cool! :) Now you should try intercepting the messages and making them do stuff.

John
03-01-2002, 07:34 AM
That will be the next step, I just thought I would give this very simple example to the forum for others to look at and play with.

This stuff is fun,
Orbity

Volte
03-01-2002, 10:31 AM
I posted it in the Code Library for you Orbity. Post any more updates in here, and I will post them to the thread in the code library.

John
03-01-2002, 11:52 AM
S W E E T !

Thanks,
Orbity

JonH
03-01-2002, 02:19 PM
Yeah, no more crash!

But what if you want to subclass more than one window / object? Take a look at my SubclassDemo. I use this Dll in every project.

More about subclassing here (http://www.vbweb.co.uk/show/49/1/), and many examples at VBnet (http://www.mvps.org/vbnet/).

JonH.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum