SubClass 1.0
by Krzysztof Swiatkowski aka Hobbit
(CP1250 Krzysztof witkowski)

0. Contents:
1. Disclaimer
2. Description
3. Example
4. Warning
5. Credits


1. Disclaimer
--------------------------------------
This component is Freeware.
It means you can do anything with it but you can't sell it and claim it is
yours. Author takes absolutely no responsibility expressed or implied for
any damage caused by this component. If law in your country does not allow
such exclusion it is illegal for you to use this component.

2. Description
--------------------------------------
Somehow I find many of components I need or use to be variations of this
simple idea. Every window or windowed control has procedure in which it
dispatches messages, this procedure is totally independent on the type of
window.
The main idea is what if I could do something with the messages my window
gets or act upon information it gives back? That way if you want to change
messages or change their parameters you do not have to write another
component, especially if it wouldn't be frequently used.
Originally Windows uses following scheme for dispatching messages from the
message queue:

Hooks
Window procedure
Default window procedure -> if window procedure did not handle the message
or after handling still requested Windows' assistance. It is done inside
window procedure.

I simply intercepted window procedure so after attaching window to
TSubclasser it is processed this way:

Hooks
OnPreProcessMsg
Window procedure
Default window procedure -> if window procedure did not handle the message
or after handling still requested Windows' assistance.
OnPostProcessMsg

There are two properties and two events:
property SubClassControl : TWinControl;
   It allows to select component at design time although nothing will
   happen then.
property SubClassHandle : HWND;
   It allows to assign handle of a window to subclass. See example 1 for
   usage.

property OnPreProcessMsg : TSubClassEvent;
   Called before message is passed to original window procedure
property OnPostProcessMsg : TSubClassEvent;
   Called after message has been passed to original window procedure

where
 TSubclassEvent = procedure (Sender: TObject; var msg : TMessage;
                            var bContinue : boolean) of object;
msg
  is the message that was received and that will be passed to original
  procedure
bContinue
  it is a flag to inform TSubclasser whether original procedure should be
  called. Setting it in OnPreprocessMsg prohibits calling OnPostProcessMsg
  handler.
          
Well thats just about it. You have a full source code adopt it to your
needs.

3. Examples
--------------------------------------
As I have put comments inside the examples you shouldn't have problems
with them. If you simply open the project without opening forms you should
be able to compile and run it without installing my component.
First example shows how to put nice background into any window, including MDIFrame.
Second shows how to make your ListBox or any other windowed control accept files.

4. Warning         
--------------------------------------
As this components copes with Windows internals it can be very dangerous.
Please do THINK before you use it, and look at the samples. This component
can be as useful as dangerous. You have been warned!

Have a nice programming! Hobbit

5.Credits
--------------------------------------
To all of my friends, especially T-1000, my primary source of Delphi
knowledge at my beginnings.

                                     
--------------------------------------
Mail me if you wish to at:
hobbit@dom.vr.pl
hobbit@priv.onet.pl

