]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/win32/winstat.cpp
Win32 build fixes
[bacula/bacula] / bacula / src / filed / win32 / 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, 2001 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 "winbacula.h"
28 #include "winstat.h"
29
30 extern void FillStatusBox(HWND hwnd, int id_list);
31
32 bacStatus::bacStatus()
33 {
34    visible = FALSE;
35 }
36
37 bacStatus::~bacStatus()
38 {
39 }
40
41
42 /* Dialog box handling functions */
43 void
44 bacStatus::Show(BOOL show)
45 {
46    if (show && !visible) {
47          DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
48              (DLGPROC)DialogProc, (LONG)this);
49    }
50 }
51
52 BOOL CALLBACK
53 bacStatus::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
54 {
55    /* Get class pointer from user data */
56    bacStatus *_this = (bacStatus *)GetWindowLong(hwnd, GWL_USERDATA);
57
58    switch (uMsg) {
59    case WM_INITDIALOG:
60       /* Set class pointer in user data */
61       SetWindowLong(hwnd, GWL_USERDATA, lParam);
62       _this = (bacStatus *)lParam;
63
64       /* show the dialog */
65       SetForegroundWindow(hwnd);
66
67       /* Update every 5 seconds */
68       SetTimer(hwnd, 1, 5000, NULL); 
69       _this->visible = TRUE;
70       FillStatusBox(hwnd, IDC_LIST);
71       return TRUE;
72
73    case WM_TIMER:
74       FillStatusBox(hwnd, IDC_LIST);
75       return TRUE;
76
77    case WM_COMMAND:
78       switch (LOWORD(wParam)) {
79       case IDCANCEL:
80       case IDOK:
81          KillTimer(hwnd, 1);
82          EndDialog(hwnd, TRUE);
83          _this->visible = FALSE;
84          return TRUE;
85       }
86       break;
87
88    case WM_DESTROY:
89       KillTimer(hwnd, 1);
90       EndDialog(hwnd, FALSE);
91       _this->visible = FALSE;
92       return TRUE;
93    }
94    return 0;
95 }