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

Last change on this file since 937 was 186, checked in by roman, 10 years ago

Additional IWMStreamConfig related data

  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2013
3// Created by Roman Ryltsov roman@alax.info
4
5#pragma once
6
7#include <atlctrls.h>
8#include <atlctrlx.h>
9#include "rocontrols.h"
10
11#pragma comment(lib, "version.lib")
12
13////////////////////////////////////////////////////////////
14// CAboutDialog
15
16class CAboutDialog : 
17        public CDialogImpl<CAboutDialog>
18{
19public:
20        enum { IDD = IDD_ABOUT };
21
22BEGIN_MSG_MAP_EX(CAboutDialog)
23        MSG_WM_INITDIALOG(OnInitDialog)
24        MSG_WM_DESTROY(OnDestroy)
25        COMMAND_ID_HANDLER_EX(IDOK, OnCommand)
26        COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
27END_MSG_MAP()
28
29protected:
30        CFont m_TitleFont;
31        CFont m_DisclaimerFont;
32        CRoHyperStatic m_WebsiteHyperStatic;
33        CRoHyperStatic m_EmailHyperStatic;
34
35public:
36// CAboutDialog
37        static CFontHandle CreateTitleFont() throw()
38        {
39                CLogFont LogFont;
40                LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(CClientDC(GetDesktopWindow()), LOGPIXELSY), 72);
41                LogFont.lfWeight = FW_BOLD;
42                LogFont.lfItalic = TRUE;
43                _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Arial"), _TRUNCATE);
44                CFont Font;
45                _W(Font.CreateFontIndirect(&LogFont));
46                return Font.Detach();
47        }
48        static CFontHandle CreateDisclaimerFont() throw()
49        {
50                CLogFont LogFont;
51                LogFont.lfHeight = -MulDiv(7, GetDeviceCaps(CClientDC(GetDesktopWindow()), LOGPIXELSY), 72);
52                LogFont.lfWeight = FW_NORMAL;
53                _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Lucida Console"), _TRUNCATE);
54                CFont Font;
55                _W(Font.CreateFontIndirect(&LogFont));
56                return Font.Detach();
57        }
58        CAboutDialog() throw()
59        {
60                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
61        }
62        ~CAboutDialog() throw()
63        {
64                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
65        }
66
67// Window message handlers
68        LRESULT OnInitDialog(HWND, LPARAM)
69        {
70                CStatic(GetDlgItem(IDC_ABOUT_ICON)).SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, 48, 48));
71                #pragma region Title Font
72                m_TitleFont = CreateTitleFont();
73                CStatic(GetDlgItem(IDC_ABOUT_TITLE)).SetFont(m_TitleFont);
74                #pragma endregion
75                #pragma region Disclaimer Font
76                {
77                        m_DisclaimerFont = CreateDisclaimerFont();
78                        CStatic CopyrightWarningText = GetDlgItem(IDC_ABOUT_COPYRIGHTWARNING);
79                        CopyrightWarningText.SetFont(m_DisclaimerFont);
80                        {
81                                CString sText = AtlLoadString(IDC_ABOUT_COPYRIGHTWARNING);
82                                CopyrightWarningText.SetWindowText(sText);
83                                CRect CurrentPosition;
84                                _W(CopyrightWarningText.GetWindowRect(CurrentPosition));
85                                CRect Position = CurrentPosition;
86                                {
87                                        CClientDC Dc(CopyrightWarningText);
88                                        CGdiSelector FontSelector(Dc, m_DisclaimerFont);
89                                        _W(Dc.DrawText(sText, -1, Position, DT_TOP | DT_LEFT | DT_WORDBREAK | DT_CALCRECT));
90                                }
91                                Position.right = CurrentPosition.right;
92                                CRect WindowPosition;
93                                _W(GetWindowRect(WindowPosition));
94                                _W(SetWindowPos(NULL, 0, 0, WindowPosition.Width(), WindowPosition.Height() + (Position.Height() - CurrentPosition.Height()), SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER));
95                                static const LONG g_nSafetyHeight = 4;
96                                _W(CopyrightWarningText.SetWindowPos(NULL, 0, 0, Position.Width(), Position.Height() + g_nSafetyHeight, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER));
97                        }
98                }
99                #pragma endregion
100                #pragma region Version Text
101                CStatic ProductVersionStatic = GetDlgItem(IDC_ABOUT_PRODUCTVERSION), FileVersionStatic = GetDlgItem(IDC_ABOUT_FILEVERSION);
102                CString sProductVersionFormat, sFileVersionFormat;
103                ProductVersionStatic.GetWindowText(sProductVersionFormat);
104                FileVersionStatic.GetWindowText(sFileVersionFormat);
105                CPath sModulePath = _VersionInfoHelper::GetModulePath();
106                ProductVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetProductVersion(sModulePath), sProductVersionFormat));
107                FileVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(sModulePath), sFileVersionFormat));
108                #pragma endregion
109                #pragma region Hyperlinks
110                _W(m_WebsiteHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_WEBSITE)));
111                _W(m_EmailHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_EMAIL)));
112                #pragma endregion
113                #pragma region Caption
114                #if _TRACE || defined(_WIN64)
115                        {
116                                CString sCaption;
117                                _W(GetWindowText(sCaption));
118                                sCaption.Append(_T(" // "));
119                                #if _DEVELOPMENT
120                                        sCaption.Append(_T("Dev "));
121                                #endif // _DEVELOPMENT
122                                sCaption.Append(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath())));
123                                #if defined(_WIN64)
124                                        sCaption.Append(_T(" (x64)"));
125                                #endif // defined(_WIN64)
126                                _W(SetWindowText(sCaption));
127                        }
128                #endif // _TRACE || defined(_WIN64)
129                #pragma endregion
130                #pragma region Window Position and Focus
131                _W(CenterWindow(GetParent()));
132                GetDlgItem(IDOK).SetFocus();
133                #pragma endregion
134                return FALSE;
135        }
136        LRESULT OnDestroy() throw()
137        {
138                _W(m_TitleFont.DeleteObject());
139                _W(m_DisclaimerFont.DeleteObject());
140                return 0;
141        }
142        LRESULT OnCommand(UINT, INT nIdentifier, HWND) throw()
143        {
144                _W(EndDialog(nIdentifier));
145                return 0;
146        }
147};
Note: See TracBrowser for help on using the repository browser.