]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/libwin32/winstat.cpp
Add all the new files from the Windows branch.
[bacula/bacula] / bacula / src / win32 / libwin32 / winstat.cpp
1 /*
2  * Bacula File daemon Status Dialog box
3  *
4  *  Inspired from the VNC code by ATT.
5  *
6  * Copyright (2000) Kern E. Sibbald
7  *
8  */
9 /*
10    Copyright (C) 2000-2003 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #include "bacula.h"
28 #include "winbacula.h"
29 #include "winstat.h"
30 #include "winres.h"
31
32 extern void FillStatusBox(HWND hwnd, int id_list);
33
34 bacStatus::bacStatus()
35 {
36    visible = FALSE;
37 }
38
39 bacStatus::~bacStatus()
40 {
41 }
42
43
44 /* Dialog box handling functions */
45 void
46 bacStatus::Show(BOOL show)
47 {
48    if (show && !visible) {
49       DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
50           (DLGPROC)DialogProc, (LONG)this);
51    }
52 }
53
54 BOOL CALLBACK
55 bacStatus::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
56 {
57    /* Get class pointer from user data */
58    bacStatus *_this = (bacStatus *)GetWindowLong(hwnd, GWL_USERDATA);
59
60    switch (uMsg) {
61    case WM_INITDIALOG:
62       /* Set class pointer in user data */
63       SetWindowLong(hwnd, GWL_USERDATA, lParam);
64       _this = (bacStatus *)lParam;
65
66       /* show the dialog */
67       SetForegroundWindow(hwnd);
68
69       /* Update every 5 seconds */
70       SetTimer(hwnd, 1, 5000, NULL); 
71       _this->visible = TRUE;
72       FillStatusBox(hwnd, IDC_LIST);
73       return TRUE;
74
75    case WM_TIMER:
76       FillStatusBox(hwnd, IDC_LIST);
77       return TRUE;
78
79    case WM_COMMAND:
80       switch (LOWORD(wParam)) {
81       case IDCANCEL:
82       case IDOK:
83          KillTimer(hwnd, 1);
84          EndDialog(hwnd, TRUE);
85          _this->visible = FALSE;
86          return TRUE;
87       }
88       break;
89
90    case WM_DESTROY:
91       KillTimer(hwnd, 1);
92       EndDialog(hwnd, FALSE);
93       _this->visible = FALSE;
94       return TRUE;
95    }
96    return 0;
97 }