-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainFrm.cpp
executable file
·162 lines (134 loc) · 4.25 KB
/
MainFrm.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
///////////////////////////////////////////////////////////////////////
// BridgeLink - BridgeLink Extensible Application Framework
// Copyright © 1999-2025 Washington State Department of Transportation
// Bridge and Structures Office
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the Alternate Route Open Source License as
// published by the Washington State Department of Transportation,
// Bridge and Structures Office.
//
// This program is distributed in the hope that it will be useful, but
// distribution is AS IS, WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the Alternate Route Open Source License for more details.
//
// You should have received a copy of the Alternate Route Open Source
// License along with this program; if not, write to the Washington
// State Department of Transportation, Bridge and Structures Office,
// P.O. Box 47340, Olympia, WA 98503, USA or e-mail
///////////////////////////////////////////////////////////////////////
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "BridgeLink.h"
#include "MainFrm.h"
#include "Resource.h"
#include "BridgeLink.hh"
#include "StartPageWndProvider.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CEAFMainFrame)
BEGIN_MESSAGE_MAP(CMainFrame, CEAFMainFrame)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//ON_WM_SYSCOMMAND()
//}}AFX_MSG_MAP
ON_COMMAND(ID_HELP_FINDER,OnHelpFinder)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame() :
CEAFMainFrame()
{
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CEAFMainFrame::OnCreate(lpCreateStruct) == -1)
return -1;
// Need to set the icon here so that GetIcon wont fail
CWinApp* pApp = AfxGetApp();
HICON hIcon = pApp->LoadIcon(IDR_MAINFRAME);
SetIcon(hIcon,TRUE);
SetIcon(hIcon,FALSE);
return 0;
}
//void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
//{
// if(nID == SC_CLOSE)
// {
// // Prompt user if he really wants to quit, but only if document is not dirty.
// // Otherwise, MFC will give it's version of "do you want to save?"
// CDocument* pdocument = (CDocument*)GetDocument();
// if (pdocument!=nullptr)
// {
// if (FALSE==pdocument->IsModified())
// {
// int st = AfxMessageBox("Do you really want to quit?",MB_YESNO);
// if (st!=IDYES)
// {
// return; // don't quit
// }
// }
// }
// }
//
// CEAFMainFrame::OnSysCommand(nID, lParam);
//}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CEAFMainFrame::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CEAFMainFrame::Dump(dc);
}
#endif //_DEBUG
CEAFStartPageWnd* CMainFrame::CreateStartPage()
{
HKEY key;
LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Washington State Department of Transportation\\BridgeLink\\Settings"),0,KEY_QUERY_VALUE,&key);
if ( result != ERROR_SUCCESS )
{
return nullptr;
}
TCHAR strCLSID[MAX_PATH];
DWORD size = MAX_PATH;
DWORD type;
result = ::RegQueryValueEx(key,_T("StartPageProvider"),0,&type,(LPBYTE)&strCLSID[0],&size);
if ( result != ERROR_SUCCESS )
{
return nullptr;
}
::RegCloseKey(key);
CLSID clsid;
HRESULT hr = ::CLSIDFromString(strCLSID,&clsid);
if ( hr != NOERROR )
{
return nullptr;
}
CComPtr<IStartPageWndProvider> provider;
if ( FAILED(provider.CoCreateInstance(clsid)) )
{
return nullptr;
}
return provider->CreateStartPage();
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnHelpFinder()
{
EAFHelp(AfxGetAppName(), IDH_BRIDGELINK);
}