Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afsapplib / afsapplib.cpp
blobae05df5d759a19c805d3ba772a7aa1d64e09a9c3
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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 */
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
15 #include <WINNT/afsapplib.h>
19 * VARIABLES __________________________________________________________________
23 static HWND g_hMain = NULL;
24 static TCHAR g_szAppName[ cchNAME ] = TEXT("");
28 * PROTOTYPES _________________________________________________________________
32 extern void OnCoverWindow (WPARAM wp, LPARAM lp);
33 extern void OnExpiredCredentials (WPARAM wp, LPARAM lp);
34 extern void OnCreateErrorDialog (WPARAM wp, LPARAM lp);
36 HRESULT CALLBACK AfsAppLib_MainHook (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
40 * ROUTINES ___________________________________________________________________
44 void AfsAppLib_SetAppName (LPTSTR pszName)
46 lstrcpy (g_szAppName, pszName);
50 void AfsAppLib_GetAppName (LPTSTR pszName)
52 lstrcpy (pszName, g_szAppName);
56 void AfsAppLib_SetMainWindow (HWND hMain)
58 if (g_hMain != NULL)
59 Subclass_RemoveHook (g_hMain, AfsAppLib_MainHook);
61 if ((g_hMain = hMain) != NULL)
62 Subclass_AddHook (g_hMain, AfsAppLib_MainHook);
66 HWND AfsAppLib_GetMainWindow (void)
68 return g_hMain;
72 HRESULT CALLBACK AfsAppLib_MainHook (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
74 PVOID oldProc = Subclass_FindNextHook (hWnd, AfsAppLib_MainHook);
76 switch (msg)
78 case WM_COVER_WINDOW:
79 OnCoverWindow (wp, lp);
80 break;
82 case WM_EXPIRED_CREDENTIALS:
83 OnExpiredCredentials (wp, lp);
84 break;
86 case WM_CREATE_ERROR_DIALOG:
87 OnCreateErrorDialog (wp, lp);
88 break;
90 case WM_DESTROY:
91 AfsAppLib_SetMainWindow (NULL);
92 break;
95 if (oldProc)
96 return (CallWindowProc ((WNDPROC)oldProc, hWnd, msg, wp, lp));
97 else
98 return (DefWindowProc (hWnd, msg, wp, lp));