Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afs_setup_utils / progress_dlg.cpp
1 /*
2  * Copyright (C) 1998  Transarc Corporation.
3  * All rights reserved.
4  *
5  */
6
7
8 /*
9  * INCLUDES ___________________________________________________________________
10  *
11  */
12 extern "C" {
13 #include <afs/param.h>
14 #include <afs/stds.h>
15 }
16
17 #include <windows.h>
18 #include <WINNT/talocale.h>
19 #include "resource.h"
20 #include "progress_dlg.h"
21 #include "animate_icon.h"
22
23
24 /*
25  * DEFINITIONS _________________________________________________________________
26  *
27  */
28
29
30 /*
31  * Variables _________________________________________________________________
32  *
33  */
34 static HWND hDlg = 0;                                           // HWND for this page's dialog
35 static char *pszProgressMsg = 0;
36 static HWND hLogo;
37
38
39 /*
40  * PROTOTYPES _________________________________________________________________
41  *
42  */
43 BOOL CALLBACK ProgressDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
44 static DWORD WINAPI DisplayProgressDlg(LPVOID param);
45 static void OnInitDialog(HWND hwndDlg);
46 static void OnQuit();
47
48
49 /*
50  * EXPORTED FUNCTIONS _________________________________________________________
51  *
52  */
53 BOOL ShowProgressDialog(char *pszMsg)
54 {
55         DWORD dwThreadID;
56         
57     pszProgressMsg = pszMsg;
58
59         // Create a thread to show the dialog
60         HANDLE hThread = CreateThread(0, 0, DisplayProgressDlg, 0, 0, &dwThreadID);
61
62         CloseHandle(hThread);
63
64     return (hThread != 0);
65 }
66
67 void HideProgressDialog(void)
68 {
69     PostMessage(hDlg, WM_QUIT, 0, 0);
70 }
71
72
73 /*
74  * Dialog Proc _________________________________________________________________
75  *
76  */
77 static BOOL CALLBACK ProgressDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
78 {
79         switch (msg) {
80                 case WM_INITDIALOG:
81             OnInitDialog(hwndDlg);
82                         hDlg = hwndDlg;
83             SetWindowText(GetDlgItem(hDlg, IDC_MSG), pszProgressMsg);
84                         break;
85     
86         case WM_QUIT:
87             OnQuit();            
88             break;
89     }
90
91     return FALSE;
92 }
93
94
95 /*
96  * Event Handler Functions __________________________________________________________
97  *
98  */
99 static void OnInitDialog(HWND hwndDlg)
100 {
101     hDlg = hwndDlg;
102
103     SetWindowText(GetDlgItem(hDlg, IDC_MSG), pszProgressMsg);
104
105     hLogo = GetDlgItem(hDlg, IDC_LOGO);
106
107     StartAnimation(hLogo, 8);
108 }
109
110 static void OnQuit()
111 {
112     StopAnimation(hLogo);
113
114     EndDialog(hDlg, IDOK);
115 }
116
117
118 /*
119  * OTHER FUNCTIONS _________________________________________________________________
120  *
121  */
122 static DWORD WINAPI DisplayProgressDlg(LPVOID param)
123 {
124         ModalDialog (IDD_PROGRESS, 0, (DLGPROC)ProgressDlgProc);
125
126         return 0;
127 }
128