![]() |
Languages »
C / C++ Language »
General
Intermediate
CHookWnd v1.02By PJ NaughterA freeware MFC class to support MFC subclassing |
VC6, MFC, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
CHookWnd, a freeware MFC class to support subclassing of any
CWnd instance. The problem it fixes is that you cannot have 2
CWnd instances attached to the one HWND at the same time. This
becomes a problem when you want to derive one of your classes from 2 base classes which
are both derived from CWnd themselves. An example is, suppose you have 2
classes namely CBitmapMenuFrameWnd, which is derived from CFrameWnd
and implements bitmap menus ALA Office 97, and CReBarFrameWnd, which
implements command bar menus ALA IE4. When you are implementing your own CMainFrame
class you then have the problem that you can only derive from one of these classes and you must
copy the source from the other one into your class.
This class fixes this problem by subclassing the window before MFC
gets to it using a plugin method. The code is based in part on a class developed by Paul
DiLascia namely "CSubclassWnd" for the MSJ magazine.
| Features |
| Usage |
| History |
| API Reference |
| Planned Enhancements |
| Contacting the Author |
CHookWnd
and override one virtual function to implement your functionality.
#include hookwnd.h in which ever of your modules needs to make calls to the class.
CHookWnd and override the virtual function
WindowProc() just like you did when you wrote your first
Windows SDK app.
History
V1.0 (25 February 1999)
V1.01 (29th March 1999)
V1.02 (10th May 1999)
HookWnd code itself.
API Reference
The API consists of the following member functions of the class CHookWnd
CHookWnd::CHookWnd
CHookWnd::~CHookWnd
CHookWnd::Hook
CHookWnd::UnHook
CHookWnd::Default
CHookWnd::WindowProc
CHookWnd::IsHooked
CHookWnd::FirstInChain
CHookWnd::LastInChain
CHookWnd::MiddleOfChain
CHookWnd::SizeOfHookChain
Remarks:
Standard C++ constructor.
Remarks:
Standard C++ destructor.
Parameters:
Remarks:
Call this member function to subclass the HWND currently subclassed
by the MFC CWnd instance "pWnd". Messages will be routed to the WindowProc
method of this instance prior to being passed of to any other installed CHookWnd's in the
chain before eventually being routed back to standard MFC message maps..
See Also:
CHookWnd::UnHook
Remarks:
Removes this instance from the chain of hooks which are handling the
subclassing.
See Also:
CHookWnd::Hook
Return Value:
The standard LRESULT which window procedures return. The actual
value will depend on the message sent.
Remarks:
You can call this function in your derived WindowProc if you want to
continue routing of the message. This will pass the message on to any other CHookWnd's in
the chain and eventually back to MFC and your message maps.
Return Value:
The standard LRESULT which window procedures return. The actual
value will depend on the message sent.
Parameters:
Remarks:
This is the function which you should override in your derived class
to implement your plugin functionality. This would appear structured very similar to an
SDK window proc. For any messages which you do not handle, you should call Default for
these.
Return Value:
TRUE if this instance is currently hooking a CWnd otherwise FALSE.
Remarks:
This function is used internally in CHookWnd as an assert in
functions where you first should have call Hook.
Return Value:
TRUE if this instance is the first in the chain of CHookWnd's
handling subclassing otherwise FALSE.
Return Value:
TRUE if this instance is the last in the chain of CHookWnd's
handling subclassing otherwise FALSE.
Return Value:
TRUE if this instance is the somewhere in the chain but is not the
first or last item in it.
Return Value:
The number of CHookWnd's in the chain which is currently handling
the subclassing.
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 3 Mar 2000 Editor: Valerie Bradley |
Copyright 2000 by PJ Naughter Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |