forked from mcneel/rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RpcAvailDialog.cpp
115 lines (88 loc) · 3.08 KB
/
RpcAvailDialog.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
#include "stdafx.h"
#include <afxdlgs.h>
#include "resource.h"
#include "RpcAvailDialog.h"
IMPLEMENT_DYNAMIC(CRpcAvailDialog, CDialog)
CRpcAvailDialog::CRpcAvailDialog(CWnd* pParent)
: CDialog(IDD_AVAIL, pParent)
{}
CRpcAvailDialog::~CRpcAvailDialog()
{}
BEGIN_MESSAGE_MAP(CRpcAvailDialog, CDialog)
ON_WM_CLOSE()
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
ON_NOTIFY(NM_CLICK, IDC_DOWNLOADS, &CRpcAvailDialog::OnLinkClicked)
END_MESSAGE_MAP()
void CRpcAvailDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_DOWNLOADS, siteLink);
DDX_Control(pDX, IDC_AVAILBROW_CONTENT, editText);
}
void CRpcAvailDialog::setText()
{
wstring text = L"RPC plugin components missing!";
text += L"\n\n- AVAIL Browser";
text += L"\n\nThe ArchVision-AVAIL apps are\nrequired to access, download\nand manage the RPC content";
text += L"\n\n\nDownload the AVAIL Browser";
editText.SetWindowText(text.c_str());
}
BOOL CRpcAvailDialog::OnInitDialog()
{
CDialog::OnInitDialog();
constexpr int DialogWidth = 244;
constexpr int DialogHeight = 319;
constexpr int DialogControlsMargin = 5;
constexpr int textEditYPos = 70;
constexpr int siteLinkYPos = 240;
this->SetWindowPos( nullptr, 0, 0, DialogWidth, DialogHeight, SWP_NOMOVE | SWP_NOZORDER );
CRect editTextRect;
editText.GetWindowRect( &editTextRect );
int textEditXPos = (DialogWidth - editTextRect.Width()) / 2 - DialogControlsMargin;
editText.SetWindowPos( nullptr, textEditXPos, textEditYPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
CRect siteLinkRect;
siteLink.GetWindowRect( &siteLinkRect );
int siteLinkXPos = (DialogWidth - siteLinkRect.Width()) / 2 - DialogControlsMargin;
siteLink.SetWindowPos( nullptr, siteLinkXPos, siteLinkYPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
setText();
siteLink.SetWindowText(L"<a href=\"https://www.archvision.com/downloads\">www.archvision.com/downloads</a>");
return TRUE;
}
BOOL CRpcAvailDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
EndDialog(0);
CDialog::OnClose();
return TRUE;
}
}
return CWnd::PreTranslateMessage(pMsg);
}
BOOL CRpcAvailDialog::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 CRpcAvailDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() != IDC_AVAILBROW_CONTENT)
pDC->SetTextColor(GetSysColor(COLOR_WINDOW));
pDC->SetBkColor(GetSysColor(COLOR_WINDOW));
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
void CRpcAvailDialog::OnLinkClicked(NMHDR* pNMHDR, LRESULT* pResult)
{
PNMLINK pNMLink = (PNMLINK)pNMHDR;
ShellExecuteW(NULL, L"open", pNMLink->item.szUrl, NULL, NULL, SW_SHOWNORMAL);
EndDialog(0);
CDialog::OnClose();
}