UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / src / win32 / winabout.cpp
blob44561005fa86bc7a6a6a5bb4434e9c48a5284ec4
1 // This file has been adapted to the Win32 version of Apcupsd
2 // by Kern E. Sibbald. Many thanks to ATT and James Weatherall,
3 // the original author, for providing an excellent template.
4 //
5 // Rewrite/Refactoring by Adam Kropelin
6 //
7 // Copyright (2007) Adam D. Kropelin
8 // Copyright (2000) Kern E. Sibbald
9 //
11 // Implementation of the About dialog
13 #include <windows.h>
14 #include <stdio.h>
15 #include "winabout.h"
16 #include "resource.h"
17 #include "version.h"
19 // Constructor/destructor
20 upsAbout::upsAbout(HINSTANCE appinst)
22 _dlgvisible = FALSE;
23 _appinst = appinst;
26 upsAbout::~upsAbout()
30 // Dialog box handling functions
31 void upsAbout::Show()
33 if (!_dlgvisible)
35 DialogBoxParam(_appinst,
36 MAKEINTRESOURCE(IDD_ABOUT),
37 NULL,
38 (DLGPROC) DialogProc,
39 (LONG) this);
43 BOOL CALLBACK upsAbout::DialogProc(
44 HWND hwnd,
45 UINT uMsg,
46 WPARAM wParam,
47 LPARAM lParam)
49 // We use the dialog-box's USERDATA to store a _this pointer
50 // This is set only once WM_INITDIALOG has been recieved, though!
51 upsAbout *_this = (upsAbout *)GetWindowLong(hwnd, GWL_USERDATA);
53 switch (uMsg)
55 case WM_INITDIALOG:
56 // Retrieve the Dialog box parameter and use it as a pointer
57 // to the calling vncProperties object
58 SetWindowLong(hwnd, GWL_USERDATA, lParam);
59 _this = (upsAbout *)lParam;
61 // Show the dialog
62 char tmp[128];
63 snprintf(tmp, sizeof(tmp), "Apctray %s (%s)", VERSION, ADATE);
64 SendDlgItemMessage(hwnd, IDC_VERSION, WM_SETTEXT, 0, (LONG)tmp);
65 SetForegroundWindow(hwnd);
66 _this->_dlgvisible = TRUE;
67 return TRUE;
69 case WM_COMMAND:
70 switch (LOWORD(wParam))
72 case IDCANCEL:
73 case IDOK:
74 // Close the dialog
75 EndDialog(hwnd, TRUE);
76 _this->_dlgvisible = FALSE;
77 return TRUE;
79 break;
81 case WM_DESTROY:
82 EndDialog(hwnd, FALSE);
83 _this->_dlgvisible = FALSE;
84 return TRUE;
87 return 0;