Subclassing in VB.NET
I must confess that I have no experience whatsover with subclassing and windows hooks in VB 6. However, reading this introduction, it looks like it would've been a while before I got a good hold of these techniques; Win32 API calls over the place - definitely not my cup of tea :) Ofcourse, that was in Visual Basic 6. DotNET seems to have made subclassing a lot easier - atleast subclassing and hooking onto windows messages in ones own application. You can read a brief introduction of how this can be accomplished here. DotNET eliminates the need of using Win32 APIs to a great extent atleast as far as subclassing is concerned. DotNET relies on, among other things, inheritance to achieve this. The Control class has a protected overridable WndProc which is in a sense the DotNET version of the Win32 API CallWindowProc. However, unlike CallWindowProc which took in 4 parameters, WndProc takes in just one - the message - which encapsulates all the parameters in a single structure. So, if one wants to modify the default behaviour of any control (including the form which eventually is inherited from the Control class), one can override the WndProc (in the left combobox in the code window, select the '(Overrides)' section and then you can select the WndProc from the right combobox) and then perform any action based on the message received.


0 Comments:
Post a Comment
<< Home