Standardize License information
[openafs.git] / src / WINNT / afslegal / afslegal.cpp
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 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include <windows.h>
16 #include <WINNT/talocale.h>
17 #include "resource.h"
18
19          // The following definition specifies the length of time that the
20          // stupid lawyer message will remain on the screen
21          //
22 #define cmsecSHOW_LAWYER_MESSAGE  5000
23
24          // Individual string resources in .RC files can't be more than 256
25          // characters long.
26          //
27 #define cchRESOURCE   256
28
29
30          // Lawyer_OnInitDialog - Populates the lawyer message window
31          //
32 void Lawyer_OnInitDialog (HWND hDlg)
33 {
34    // Make the title item boldfaced
35    //
36    HFONT hfOld = (HFONT)SendDlgItemMessage (hDlg, IDC_TITLE, WM_GETFONT, 0, 0);
37
38    LOGFONT lf;
39    GetObject (hfOld, sizeof(lf), &lf);
40
41    lf.lfWeight = FW_BOLD;
42
43    SendDlgItemMessage (hDlg, IDC_TITLE, WM_SETFONT, (WPARAM)CreateFontIndirect (&lf), 0);
44
45    // Allocate a buffer, load the string, and shove the text
46    // in the main window.
47    //
48    LPTSTR pszMessage = FormatString (TEXT("%1"), TEXT("%m"), IDS_MESSAGE_1);
49
50    SetDlgItemText (hDlg, IDC_MESSAGE, pszMessage);
51
52    FreeString (pszMessage);
53 }
54
55
56          // Lawyer_DlgProc - The window procedure for the lawyer message
57          //
58 BOOL CALLBACK Lawyer_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
59 {
60    switch (msg)
61       {
62       case WM_INITDIALOG:
63          Lawyer_OnInitDialog (hDlg);
64          SetTimer (hDlg, 0, cmsecSHOW_LAWYER_MESSAGE, NULL);
65          break;
66
67       case WM_DESTROY:
68          PostQuitMessage (0);
69          break;
70
71       case WM_TIMER:
72          DestroyWindow (hDlg);
73          KillTimer (hDlg, 0);
74          break;
75
76       case WM_CTLCOLORSTATIC:
77          if ((HWND)lp == GetDlgItem (hDlg, IDC_MESSAGE))
78             {
79             static HBRUSH hbrBackground = CreateSolidBrush (GetSysColor (COLOR_BTNFACE));
80             SetBkColor ((HDC)wp, GetSysColor (COLOR_BTNFACE));
81             SetTextColor ((HDC)wp, GetSysColor (COLOR_WINDOWTEXT));
82             return (BOOL)hbrBackground;
83             }
84          break;
85
86       case WM_COMMAND:
87          if (LOWORD(wp) ==  IDCANCEL)
88             DestroyWindow (hDlg);
89          break;
90       }
91
92    return FALSE;
93 }
94
95
96          // WinMain - Creates the window, waits for it to terminate
97          //
98 int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
99 {
100    TaLocale_LoadCorrespondingModule (hInst);
101
102    HWND hDlg = ModelessDialog (IDD_LAWYER, NULL, (DLGPROC)Lawyer_DlgProc);
103    SetWindowPos (hDlg, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
104
105    MSG msg;
106    while (GetMessage (&msg, NULL, 0, 0))
107       {
108       if (!IsDialogMessage (hDlg, &msg))
109          {
110          TranslateMessage (&msg);
111          DispatchMessage (&msg);
112          }
113       }
114
115    return 0;
116 }
117