-
Notifications
You must be signed in to change notification settings - Fork 5
/
RpcAboutDialog.cpp
134 lines (105 loc) · 3.36 KB
/
RpcAboutDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "stdafx.h"
#include <afxdlgs.h>
#include "resource.h"
#include "RpcAboutDialog.h"
#include "RPCPlugIn.h"
IMPLEMENT_DYNAMIC(RpcAboutDialog, CDialog)
RpcAboutDialog::RpcAboutDialog(CWnd* pParent)
: CDialog(IDD_ABOUT, pParent)
{}
RpcAboutDialog::~RpcAboutDialog()
{}
BEGIN_MESSAGE_MAP(RpcAboutDialog, CDialog)
ON_WM_CLOSE()
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
ON_NOTIFY(NM_CLICK, IDC_ARCHSITE, &RpcAboutDialog::OnLinkClicked)
END_MESSAGE_MAP()
void RpcAboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ARCHSITE, siteLink);
DDX_Control(pDX, IDC_ABOUT_TEXT, editText);
}
wstring RpcAboutDialog::getDllVersion(const wchar_t* path)
{
wstring version = L"1.0.0.0";
DWORD handle = 0;
DWORD verSize = GetFileVersionInfoSize(path, &handle);
if (!verSize)
return version;
std::vector<uint8_t> verInfoBuffer(verSize);
if (!GetFileVersionInfo(path, handle, verSize, verInfoBuffer.data()))
return version;
LPBYTE lpBuffer = nullptr;
UINT size = 0;
if (!VerQueryValueW(verInfoBuffer.data(), L"\\", (LPVOID*)&lpBuffer, &size)
|| !size)
return version;
VS_FIXEDFILEINFO* verInfo = (VS_FIXEDFILEINFO*)lpBuffer;
if (verInfo->dwSignature == 0xfeef04bd)
{
version =
to_wstring((verInfo->dwFileVersionMS >> 16) & 0xffff) + L"." +
to_wstring((verInfo->dwFileVersionMS >> 0) & 0xffff) + L"." +
to_wstring((verInfo->dwFileVersionLS >> 16) & 0xffff) + L"." +
to_wstring((verInfo->dwFileVersionLS >> 0) & 0xffff);
}
return version;
}
void RpcAboutDialog::setVersion()
{
wstring text = getVersionString() + L"\n\nCheck out more information at";
editText.SetWindowText(text.c_str());
}
wstring RpcAboutDialog::getVersionString()
{
wstring text = L"RPC Plugin " + getDllVersion(PlugIn().PlugInFileName())
+ L"\n\nRPC Render API\nVersion " + getDllVersion(PlugIn().getRpcApiFilename())
+ L"\n\nCopyright © 1998-2022\nArchVision Inc.";
return text;
}
BOOL RpcAboutDialog::OnInitDialog()
{
CDialog::OnInitDialog();
setVersion();
siteLink.SetWindowText(L"<a href=\"https://www.archvision.com\">www.archvision.com</a>");
return TRUE;
}
BOOL RpcAboutDialog::PreTranslateMessage(MSG * pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
EndDialog(0);
CDialog::OnClose();
return TRUE;
}
}
return CWnd::PreTranslateMessage(pMsg);
}
BOOL RpcAboutDialog::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
CBrush* myBrush = new CBrush(GetSysColor(COLOR_WINDOW));
pDC->SelectObject(myBrush);
BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
return bRes;
}
HBRUSH RpcAboutDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() != IDC_ABOUT_TEXT)
pDC->SetTextColor(GetSysColor(COLOR_WINDOW));
pDC->SetBkColor(GetSysColor(COLOR_WINDOW));
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
void RpcAboutDialog::OnLinkClicked(NMHDR* pNMHDR, LRESULT* pResult)
{
PNMLINK pNMLink = (PNMLINK)pNMHDR;
ShellExecuteW(NULL, L"open", pNMLink->item.szUrl, NULL, NULL, SW_SHOWNORMAL);
EndDialog(0);
CDialog::OnClose();
}