2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Bacula File daemon Status Dialog box
31 * Kern Sibbald, August 2007
38 #include "statusDialog.h"
39 #include "lib/status.h"
41 static BOOL CALLBACK dialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
43 /* Get class pointer from user data */
44 statusDialog *statDlg = (statusDialog *)GetWindowLong(hDlg, GWL_USERDATA);
48 /* Set class pointer in user data */
49 SetWindowLong(hDlg, GWL_USERDATA, lParam);
50 statDlg = (statusDialog *)lParam;
51 statDlg->m_textWin = GetDlgItem(hDlg, IDC_TEXTDISPLAY);
54 SetForegroundWindow(hDlg);
56 /* Update every 5 seconds */
57 SetTimer(hDlg, 1, 5000, NULL);
58 statDlg->m_visible = true;
67 statDlg->resize(hDlg, LOWORD(lParam), HIWORD(lParam));
71 switch (LOWORD(wParam)) {
74 statDlg->m_visible = false;
76 EndDialog(hDlg, true);
82 statDlg->m_textWin = NULL;
83 statDlg->m_visible = false;
85 EndDialog(hDlg, false);
92 static void displayString(const char *msg, int len, void *context)
94 /* Get class pointer from user data */
95 statusDialog *statDlg = (statusDialog *)context;
96 const char *start = msg;
100 for (p=start; *p; p++) {
104 str = (char *)alloca(len + 1);
105 bstrncpy(str, start, len + 1);
107 SendMessage(statDlg->m_textWin, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
108 SendMessage(statDlg->m_textWin, EM_REPLACESEL, 0, (LPARAM)str);
112 SendMessage(statDlg->m_textWin, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
113 SendMessage(statDlg->m_textWin, EM_REPLACESEL, 0, (LPARAM)"\r\n");
124 void statusDialog::display()
126 if (m_textWin != NULL) {
128 long hPos = GetScrollPos(m_textWin, SB_HORZ);
129 long vPos = GetScrollPos(m_textWin, SB_VERT);
133 SendMessage(m_textWin, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
135 SetWindowText(m_textWin, "");
138 sp.callback = displayString;
141 SendMessage(m_textWin, EM_SETSEL, selStart, selEnd);
142 SendMessage(m_textWin, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, hPos), 0);
143 SendMessage(m_textWin, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, vPos), 0);
147 /* Dialog box handling functions */
148 void statusDialog::show(bool show)
150 if (show && !m_visible) {
151 DialogBoxParam(appInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
152 (DLGPROC)dialogProc, (LPARAM)this);
157 * Make sure OK button is positioned in the right place
159 void statusDialog::resize(HWND dWin, int dWidth, int dHeight)
165 if (m_textWin != NULL) {
166 bWin = GetDlgItem(dWin, IDOK); /* get size of OK button */
168 GetWindowRect(bWin, &bRect);
169 bWidth = bRect.right - bRect.left;
170 bHeight = bRect.bottom - bRect.top;
172 MoveWindow(m_textWin, 8, 8, dWidth-bWidth-24, dHeight-16, true);
173 MoveWindow(bWin, dWidth - bWidth-8, 8, bWidth, bHeight, true);