source: trunk/Utilities/LogProcessExceptions/AboutDialog.h @ 937

Last change on this file since 937 was 61, checked in by roman, 12 years ago
  • moved from assembla
  • early add Debug privilege in order to be able to list service processes
  • cosmetic fix
  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1////////////////////////////////////////////////////////////
2// AboutDialog.h -
3//
4// Created by Roman Ryltsov roman@alax.info
5//
6// $Id: AboutDialog.h 61 2012-04-27 10:54:06Z roman $
7
8#pragma once
9
10#include <atlctrls.h>
11#include <atlctrlx.h>
12#include "rocontrols.h"
13
14#pragma comment(lib, "version.lib")
15
16////////////////////////////////////////////////////////////
17// CAboutDialog
18
19class CAboutDialog : 
20        public CDialogImpl<CAboutDialog>
21{
22public:
23
24        enum { IDD = IDD_ABOUT };
25
26BEGIN_MSG_MAP_EX(CAboutDialog)
27        MSG_WM_INITDIALOG(OnInitDialog)
28        MSG_WM_DESTROY(OnDestroy)
29        COMMAND_ID_HANDLER_EX(IDOK, OnCommand)
30        COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
31END_MSG_MAP()
32
33protected:
34        CFont m_TitleFont;
35        CFont m_DisclaimerFont;
36        CRoHyperStatic m_WebsiteHyperStatic;
37        CRoHyperStatic m_EmailHyperStatic;
38
39public:
40// CAboutDialog
41        CAboutDialog() throw()
42        {
43                _Z4(atlTraceRefcount, 4, _T("this 0x%08x\n"), this);
44        }
45        ~CAboutDialog() throw()
46        {
47                _Z4(atlTraceRefcount, 4, _T("this 0x%08x\n"), this);
48        }
49
50// Window message handlers
51        LRESULT OnInitDialog(HWND, LPARAM)
52        {
53                CStatic(GetDlgItem(IDC_ABOUT_ICON)).SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, 48, 48));
54                // Create and apply title font
55                {
56                        CLogFont LogFont;
57                        LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(CClientDC(m_hWnd), LOGPIXELSY), 72);
58                        LogFont.lfWeight = FW_BOLD;
59                        LogFont.lfItalic = TRUE;
60                        _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Arial"), _TRUNCATE);
61                        _W(m_TitleFont.CreateFontIndirect(&LogFont));
62                        CStatic(GetDlgItem(IDC_ABOUT_TITLE)).SetFont(m_TitleFont);
63                }
64                // Create and apply disclaimer font
65                {
66                        CLogFont LogFont;
67                        LogFont.lfHeight = -MulDiv(7, GetDeviceCaps(CClientDC(m_hWnd), LOGPIXELSY), 72);
68                        LogFont.lfWeight = FW_NORMAL;
69                        _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Lucida Console"), _TRUNCATE);
70                        _W(m_DisclaimerFont.CreateFontIndirect(&LogFont));
71                        CStatic CopyrightWarningText = GetDlgItem(IDC_ABOUT_COPYRIGHTWARNING);
72                        CopyrightWarningText.SetFont(m_DisclaimerFont);
73                        {
74                                CString sText = AtlLoadString(IDC_ABOUT_COPYRIGHTWARNING);
75                                CopyrightWarningText.SetWindowText(sText);
76                                CRect CurrentPosition;
77                                _W(CopyrightWarningText.GetWindowRect(CurrentPosition));
78                                CRect Position = CurrentPosition;
79                                {
80                                        CClientDC Dc(CopyrightWarningText);
81                                        CGdiSelector FontSelector(Dc, m_DisclaimerFont);
82                                        _W(Dc.DrawText(sText, -1, Position, DT_TOP | DT_LEFT | DT_WORDBREAK | DT_CALCRECT));
83                                }
84                                Position.right = CurrentPosition.right;
85                                CRect WindowPosition;
86                                _W(GetWindowRect(WindowPosition));
87                                _W(SetWindowPos(NULL, 0, 0, WindowPosition.Width(), WindowPosition.Height() + (Position.Height() - CurrentPosition.Height()), SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER));
88                                static const LONG g_nSafetyHeight = 4;
89                                _W(CopyrightWarningText.SetWindowPos(NULL, 0, 0, Position.Width(), Position.Height() + g_nSafetyHeight, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER));
90                        }
91                }
92                // Update version text
93                CStatic ProductVersionStatic = GetDlgItem(IDC_ABOUT_PRODUCTVERSION), FileVersionStatic = GetDlgItem(IDC_ABOUT_FILEVERSION);
94                CString sProductVersionFormat, sFileVersionFormat;
95                ProductVersionStatic.GetWindowText(sProductVersionFormat);
96                FileVersionStatic.GetWindowText(sFileVersionFormat);
97                CPath sModulePath = _VersionInfoHelper::GetModulePath();
98                ProductVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetProductVersion(sModulePath), sProductVersionFormat));
99                FileVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(sModulePath), sFileVersionFormat));
100                // Update hyperlinks
101                _W(m_WebsiteHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_WEBSITE)));
102                _W(m_EmailHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_EMAIL)));
103                // Update caption
104                {
105#if _TRACE
106                        CString sCaption;
107                        _W(GetWindowText(sCaption));
108                        sCaption.Append(_T(" // "));
109#if _DEVELOPMENT
110                        sCaption.Append(_T("Dev "));
111#endif // _DEVELOPMENT
112                        sCaption.Append(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath())));
113                        _W(SetWindowText(sCaption));
114#endif // _TRACE
115                }
116                // Update window position and focus
117                _W(CenterWindow(GetParent()));
118                GetDlgItem(IDOK).SetFocus();
119                return FALSE;
120        }
121        LRESULT OnDestroy() throw()
122        {
123                _W(m_TitleFont.DeleteObject());
124                _W(m_DisclaimerFont.DeleteObject());
125                return 0;
126        }
127        LRESULT OnCommand(UINT, INT nIdentifier, HWND) throw()
128        {
129                _W(EndDialog(nIdentifier));
130                return 0;
131        }
132};
Note: See TracBrowser for help on using the repository browser.