source: trunk/DirectShowSpy/AboutDialog.h @ 147

Last change on this file since 147 was 95, checked in by roman, 12 years ago

DirectShowSpy? moved from Assembla

File size: 4.8 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2011
3// Created by Roman Ryltsov roman@alax.info
4//
5// $Id: AboutDialog.h 302 2011-07-26 08:46:45Z alax $
6
7#pragma once
8
9#include <atlctrls.h>
10#include <atlctrlx.h>
11#include "rocontrols.h"
12
13#pragma comment(lib, "version.lib")
14
15////////////////////////////////////////////////////////////
16// CAboutDialog
17
18class CAboutDialog : 
19        public CDialogImpl<CAboutDialog>
20{
21public:
22
23        enum { IDD = IDD_ABOUT };
24
25BEGIN_MSG_MAP_EX(CAboutDialog)
26        MSG_WM_INITDIALOG(OnInitDialog)
27        MSG_WM_DESTROY(OnDestroy)
28        COMMAND_ID_HANDLER_EX(IDOK, OnCommand)
29        COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
30END_MSG_MAP()
31
32protected:
33        CFont m_TitleFont;
34        CFont m_DisclaimerFont;
35        CRoHyperStatic m_WebsiteHyperStatic;
36        CRoHyperStatic m_EmailHyperStatic;
37
38public:
39// CAboutDialog
40        CAboutDialog() throw()
41        {
42                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
43        }
44        ~CAboutDialog() throw()
45        {
46                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
47        }
48
49// Window message handlers
50        LRESULT OnInitDialog(HWND, LPARAM)
51        {
52                CStatic(GetDlgItem(IDC_ABOUT_ICON)).SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, 48, 48));
53                #pragma region Create and apply title font
54                {
55                        CLogFont LogFont;
56                        LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(CClientDC(m_hWnd), LOGPIXELSY), 72);
57                        LogFont.lfWeight = FW_BOLD;
58                        LogFont.lfItalic = TRUE;
59                        _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Arial"), _TRUNCATE);
60                        _W(m_TitleFont.CreateFontIndirect(&LogFont));
61                        CStatic(GetDlgItem(IDC_ABOUT_TITLE)).SetFont(m_TitleFont);
62                }
63                #pragma endregion
64                #pragma region 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                #pragma endregion
93                #pragma region Update version text
94                CStatic ProductVersionStatic = GetDlgItem(IDC_ABOUT_PRODUCTVERSION), FileVersionStatic = GetDlgItem(IDC_ABOUT_FILEVERSION);
95                CString sProductVersionFormat, sFileVersionFormat;
96                ProductVersionStatic.GetWindowText(sProductVersionFormat);
97                FileVersionStatic.GetWindowText(sFileVersionFormat);
98                CPath sModulePath = _VersionInfoHelper::GetModulePath();
99                ProductVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetProductVersion(sModulePath), sProductVersionFormat));
100                FileVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(sModulePath), sFileVersionFormat));
101                #pragma endregion
102                #pragma region Update hyperlinks
103                _W(m_WebsiteHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_WEBSITE)));
104                _W(m_EmailHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_EMAIL)));
105                #pragma endregion
106                #pragma region Update caption
107                {
108#if _TRACE
109                        CString sCaption;
110                        _W(GetWindowText(sCaption));
111                        sCaption.Append(_T(" // "));
112#if _DEVELOPMENT
113                        sCaption.Append(_T("Dev "));
114#endif // _DEVELOPMENT
115                        sCaption.Append(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath())));
116                        _W(SetWindowText(sCaption));
117#endif // _TRACE
118                }
119                #pragma endregion
120                #pragma region Update window position and focus
121                _W(CenterWindow(GetParent()));
122                GetDlgItem(IDOK).SetFocus();
123                #pragma endregion
124                return FALSE;
125        }
126        LRESULT OnDestroy() throw()
127        {
128                _W(m_TitleFont.DeleteObject());
129                _W(m_DisclaimerFont.DeleteObject());
130                return 0;
131        }
132        LRESULT OnCommand(UINT, INT nIdentifier, HWND) throw()
133        {
134                _W(EndDialog(nIdentifier));
135                return 0;
136        }
137};
Note: See TracBrowser for help on using the repository browser.