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 John Walker.
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"
40 static BOOL CALLBACK dialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
42 /* Get class pointer from user data */
43 statusDialog *statDlg = (statusDialog *)GetWindowLong(hDlg, GWL_USERDATA);
47 /* Set class pointer in user data */
48 SetWindowLong(hDlg, GWL_USERDATA, lParam);
49 statDlg = (statusDialog *)lParam;
50 statDlg->m_textWin = GetDlgItem(hDlg, IDC_TEXTDISPLAY);
53 SetForegroundWindow(hDlg);
55 /* Update every 5 seconds */
56 SetTimer(hDlg, 1, 5000, NULL);
57 statDlg->m_visible = true;
66 statDlg->resize(hDlg, LOWORD(lParam), HIWORD(lParam));
70 switch (LOWORD(wParam)) {
73 statDlg->m_visible = false;
75 EndDialog(hDlg, true);
81 statDlg->m_textWin = NULL;
82 statDlg->m_visible = false;
84 EndDialog(hDlg, false);
91 static void displayString(const char *msg, int len, void *context)
93 /* Get class pointer from user data */
94 statusDialog *statDlg = (statusDialog *)context;
95 const char *start = msg;
99 for (p=start; *p; p++) {
103 str = (char *)alloca(len + 1);
104 bstrncpy(str, start, len + 1);
106 SendMessage(statDlg->m_textWin, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
107 SendMessage(statDlg->m_textWin, EM_REPLACESEL, 0, (LPARAM)str);
111 SendMessage(statDlg->m_textWin, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
112 SendMessage(statDlg->m_textWin, EM_REPLACESEL, 0, (LONG)"\r\n");
123 void statusDialog::display()
125 if (m_textWin != NULL) {
126 long hPos = GetScrollPos(m_textWin, SB_HORZ);
127 long vPos = GetScrollPos(m_textWin, SB_VERT);
131 SendMessage(m_textWin, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
133 SetWindowText(m_textWin, "");
134 output_status(displayString, this);
136 SendMessage(m_textWin, EM_SETSEL, selStart, selEnd);
137 SendMessage(m_textWin, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, hPos), 0);
138 SendMessage(m_textWin, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, vPos), 0);
142 /* Dialog box handling functions */
143 void statusDialog::show(bool show)
145 if (show && !m_visible) {
146 DialogBoxParam(appInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
147 (DLGPROC)dialogProc, (LONG)this);
152 * Make sure OK button is positioned in the right place
154 void statusDialog::resize(HWND dWin, int dWidth, int dHeight)
160 if (m_textWin != NULL) {
161 bWin = GetDlgItem(dWin, IDOK); /* get size of OK button */
163 GetWindowRect(bWin, &bRect);
164 bWidth = bRect.right - bRect.left;
165 bHeight = bRect.bottom - bRect.top;
167 MoveWindow(m_textWin, 8, 8, dWidth-bWidth-24, dHeight-16, true);
168 MoveWindow(bWin, dWidth - bWidth-8, 8, bWidth, bHeight, true);