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