/
Thresholding1.cpp
145 lines (115 loc) · 3.37 KB
/
Thresholding1.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
// Thresholding1.cpp : 定义应用程序的类行为。
//
#include "stdafx.h"
#include "Thresholding1.h"
#include "Thresholding1Dlg.h"
#include <initguid.h>
#include "Thresholding1_i.c"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CThresholding1App
class CThresholding1Module :
public ATL::CAtlMfcModule
{
public:
DECLARE_LIBID(LIBID_Thresholding1Lib);
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_THRESHOLDING1, "{993B1E6F-2EB9-486A-AB2D-1D2CF8AA4969}");};
CThresholding1Module _AtlModule;
BEGIN_MESSAGE_MAP(CThresholding1App, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CThresholding1App 构造
CThresholding1App::CThresholding1App()
{
// 支持重新启动管理器
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}
// 唯一的一个 CThresholding1App 对象
CThresholding1App theApp;
// CThresholding1App 初始化
BOOL CThresholding1App::InitInstance()
{
AfxOleInit();
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
#if !defined(_WIN32_WCE) || defined(_CE_DCOM)
// 通过 CoRegisterClassObject() 注册类工厂。
if (FAILED(_AtlModule.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE)))
return FALSE;
#endif // !defined(_WIN32_WCE) || defined(_CE_DCOM)
// 应用程序是用 /Embedding 或 /Automation 开关启动的。
// 将应用程序作为自动化服务器运行。
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// 不显示主窗口
return TRUE;
}
// 应用程序是用 /Unregserver 或 /Unregister 开关启动的。
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
_AtlModule.UpdateRegistryAppId(FALSE);
_AtlModule.UnregisterServer(TRUE);
return FALSE;
}
// 应用程序是用 /Register 或 /Regserver 开关启动的。
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
{
_AtlModule.UpdateRegistryAppId(TRUE);
_AtlModule.RegisterServer(TRUE);
return FALSE;
}
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = new CShellManager;
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
CThresholding1Dlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
// 删除上面创建的 shell 管理器。
if (pShellManager != NULL)
{
delete pShellManager;
}
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
// 而不是启动应用程序的消息泵。
return FALSE;
}
BOOL CThresholding1App::ExitInstance(void)
{
#if !defined(_WIN32_WCE) || defined(_CE_DCOM)
_AtlModule.RevokeClassObjects();
#endif
return CWinApp::ExitInstance();
}