Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afsapplib / subclass.h
1 #ifndef SUBCLASS_H
2 #define SUBCLASS_H
3
4 /*
5  * DEFINITIONS ________________________________________________________________
6  *
7  */
8
9 #ifndef EXPORTED
10 #define EXPORTED
11 #endif
12
13
14 /*
15  * PROTOTYPES _________________________________________________________________
16  *
17  * These routines provide a consistent method for multiple children in
18  * a dialog to add and remove subclasses, without stepping on each
19  * others' toes.
20  *
21  * Old code like this:
22  *
23  *    // Install subclass on create
24  *    LONG oldProc = GetWindowLong (hWnd, GWL_WNDPROC);
25  *    SetWindowLong (hWnd, GWL_WNDPROC, (LONG)MyWindowProc);
26  *
27  *    // Use
28  *    if (oldProc)
29  *       CallWindowProc(oldProc,hWnd,msg,wp,lp);
30  *    else
31  *       DefWindowProc(hWnd,msg,wp,lp);
32  *
33  *    // Uninstall subclass on destroy
34  *    SetWindowLong (hWnd, GWL_WNDPROC, (LONG)oldProc);
35  *
36  * Will eat itself unless all changes are peeled back in the opposite
37  * order in which subclasses were installed.  This technique won't:
38  *
39  *    // Install subclass on create
40  *    Subclass_AddHook (hWnd, MyWindowProc);
41  *
42  *    // Use
43  *    PVOID oldProc = Subclass_FindNextHook (hWnd, MyWindowProc);
44  *    if (oldProc)
45  *       CallWindowProc(oldProc,hWnd,msg,wp,lp);
46  *    else
47  *       DefWindowProc(hWnd,msg,wp,lp);
48  *
49  *    // Uninstall subclass on destroy
50  *    Subclass_RemoveHook (hWnd, MyWindowProc);
51  *
52  * Note that if five calls are made to add "Subclass_AddHook" giving
53  * the same hTarget and wndProc, then five successive calls to _Remove
54  * will be necessary to remove the hook; also note that the wndProc
55  * will (of course) be called only *once* per message.
56  *
57  */
58
59 EXPORTED BOOL Subclass_AddHook (HWND hTarget, PVOID wndProc);
60 EXPORTED void Subclass_RemoveHook (HWND hTarget, PVOID wndProc);
61 EXPORTED PVOID Subclass_FindNextHook (HWND hTarget, PVOID wndProcMine);
62
63
64 #endif
65