ticket-2618-patches-20031207
[openafs.git] / src / WINNT / afsapplib / subclass.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef SUBCLASS_H
11 #define SUBCLASS_H
12
13 /*
14  * DEFINITIONS ________________________________________________________________
15  *
16  */
17
18 #ifndef EXPORTED
19 #define EXPORTED
20 #endif
21
22
23 /*
24  * PROTOTYPES _________________________________________________________________
25  *
26  * These routines provide a consistent method for multiple children in
27  * a dialog to add and remove subclasses, without stepping on each
28  * others' toes.
29  *
30  * Old code like this:
31  *
32  *    // Install subclass on create
33  *    LONG oldProc = GetWindowLong (hWnd, GWL_WNDPROC);
34  *    SetWindowLong (hWnd, GWL_WNDPROC, (LONG)MyWindowProc);
35  *
36  *    // Use
37  *    if (oldProc)
38  *       CallWindowProc(oldProc,hWnd,msg,wp,lp);
39  *    else
40  *       DefWindowProc(hWnd,msg,wp,lp);
41  *
42  *    // Uninstall subclass on destroy
43  *    SetWindowLong (hWnd, GWL_WNDPROC, (LONG)oldProc);
44  *
45  * Will eat itself unless all changes are peeled back in the opposite
46  * order in which subclasses were installed.  This technique won't:
47  *
48  *    // Install subclass on create
49  *    Subclass_AddHook (hWnd, MyWindowProc);
50  *
51  *    // Use
52  *    PVOID oldProc = Subclass_FindNextHook (hWnd, MyWindowProc);
53  *    if (oldProc)
54  *       CallWindowProc(oldProc,hWnd,msg,wp,lp);
55  *    else
56  *       DefWindowProc(hWnd,msg,wp,lp);
57  *
58  *    // Uninstall subclass on destroy
59  *    Subclass_RemoveHook (hWnd, MyWindowProc);
60  *
61  * Note that if five calls are made to add "Subclass_AddHook" giving
62  * the same hTarget and wndProc, then five successive calls to _Remove
63  * will be necessary to remove the hook; also note that the wndProc
64  * will (of course) be called only *once* per message.
65  *
66  */
67
68 EXPORTED BOOL Subclass_AddHook (HWND hTarget, PVOID wndProc);
69 EXPORTED void Subclass_RemoveHook (HWND hTarget, PVOID wndProc);
70 EXPORTED PVOID Subclass_FindNextHook (HWND hTarget, PVOID wndProcMine);
71
72
73 #endif
74