提交 74120ad5 编写于 作者: 御承扬

添加项目文件。

上级 f543ce17

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "数据库操作", "数据库操作\数据库操作.vcxproj", "{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Debug|x64.ActiveCfg = Debug|x64
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Debug|x64.Build.0 = Debug|x64
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Debug|x86.ActiveCfg = Debug|Win32
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Debug|x86.Build.0 = Debug|Win32
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Release|x64.ActiveCfg = Release|x64
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Release|x64.Build.0 = Release|x64
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Release|x86.ActiveCfg = Release|Win32
{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8EFC9E71-0781-4F29-B84E-3B8AFD116CCB}
EndGlobalSection
EndGlobal

// ChildFrm.cpp: CChildFrame 类的实现
//
#include "stdafx.h"
#include "数据库操作.h"
#include "ChildFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
END_MESSAGE_MAP()
// CChildFrame 构造/析构
CChildFrame::CChildFrame() noexcept
{
// TODO: 在此添加成员初始化代码
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
// CChildFrame 诊断
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
// CChildFrame 消息处理程序

// ChildFrm.h: CChildFrame 类的接口
//
#pragma once
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame() noexcept;
// 特性
protected:
CSplitterWnd m_wndSplitter;
public:
// 操作
public:
// 重写
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// 实现
public:
virtual ~CChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
};
// DBOption.cpp: 实现文件
//
#include "stdafx.h"
#include "数据库操作.h"
#include "DBOption.h"
#include "afxdialogex.h"
// CDBOption 对话框
IMPLEMENT_DYNAMIC(CDBOption, CDialogEx)
CDBOption::CDBOption(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DB, pParent)
, m_ID(_T(""))
, m_Name(_T(""))
, m_Sex(_T(""))
, m_Age(_T(""))
{
}
CDBOption::~CDBOption()
{
}
BOOL CDBOption::InitInstance()
{
AfxOleInit();
return TRUE;
}
void CDBOption::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_LOG, m_editLog);
DDX_Text(pDX, IDC_EDIT_ID, m_ID);
DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
DDX_Text(pDX, IDC_EDIT_SEX, m_Sex);
DDX_Text(pDX, IDC_EDIT_AGE, m_Age);
}
BEGIN_MESSAGE_MAP(CDBOption, CDialogEx)
ON_BN_CLICKED(IDOK, &CDBOption::OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON_CONNECT, &CDBOption::OnButtonConnect)
ON_BN_CLICKED(IDC_BUTTON_READ, &CDBOption::OnButtonRead)
ON_BN_CLICKED(IDC_BUTTON_FIRST, &CDBOption::OnButtonFirst)
ON_BN_CLICKED(IDC_BUTTON_LAST, &CDBOption::OnButtonLast)
ON_BN_CLICKED(IDC_BUTTON_NEXT, &CDBOption::OnButtonNext)
ON_BN_CLICKED(IDC_BUTTON_PREV, &CDBOption::OnButtonPrev)
ON_BN_CLICKED(IDC_BUTTON_WRITE, &CDBOption::OnButtonWrite)
ON_BN_CLICKED(IDC_BUTTON_DELETE, &CDBOption::OnButtonDelete)
END_MESSAGE_MAP()
// CDBOption 消息处理程序
void CDBOption::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
CDialogEx::OnOK();
}
void CDBOption::OnButtonConnect()
{
// TODO: 在此添加控件通知处理程序代码
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");
if (SUCCEEDED(hr)) //如果ADO实例创建成功
{
hr = m_pConnection->Open("driver={SQL Server};Server=御承扬;Database=TEST1;UID=pyc-ycy;PWD=789147;", "", "", adModeUnknown);
}
if (m_pConnection->State)
m_editLog.SetWindowText(L"数据库连接成功");
else
m_editLog.SetWindowText(L"数据库连接失败");
}
catch (_com_error e)
{
CString log;
log.Format(L"数据库连接失败!\r\n原因:%s", e.ErrorMessage());
MessageBox(log, L"提示", MB_ICONASTERISK);
}
}
void CDBOption::GetRecordContent()
{
if (m_pRecordset == NULL) //记录集为NULL
return;
if (m_pRecordset->BOF || m_pRecordset->adoEOF) //记录是头或尾
return;
_variant_t vID, vName, vSex, vAge;
vID = m_pRecordset->GetCollect("ID");
vName = m_pRecordset->GetCollect("Agent_Name");
vSex = m_pRecordset->GetCollect("Sex");
vAge = m_pRecordset->GetCollect("Age");
m_ID = (LPCTSTR)(_bstr_t)(vID);
m_Name = (LPCTSTR)(_bstr_t)(vName);
m_Sex = (LPCTSTR)(_bstr_t)(vSex);
m_Age = (LPCTSTR)(_bstr_t)(vAge);
UpdateData(false);
}
void CDBOption::OnButtonRead()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pConnection == NULL)
{
MessageBox(L"数据库还未连接\r\n,请连接后再重复此操作", L"提示", MB_ICONASTERISK);
return; //如果还未连接,则返回
}
m_pConnection->CursorLocation = adUseServer; //设置连接使用光标类型
m_pRecordset.CreateInstance("ADODB.Recordset"); //创建记录对象
m_pRecordset->Open("SELECT * FROM Agent",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockBatchOptimistic,adCmdText);
GetRecordContent();
}
void CDBOption::OnButtonFirst()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pRecordset == NULL) //如果记录集为空
return;
m_pRecordset->MoveFirst(); //移动到记录集里的第一条记录
GetRecordContent();
}
void CDBOption::OnButtonLast()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pRecordset == NULL) //如果记录集为空
return;
m_pRecordset->MoveLast(); //移动到记录集里的最后一条记录
GetRecordContent();
}
void CDBOption::OnButtonNext()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pRecordset == NULL) //如果记录集为空
return;
if (m_pRecordset->adoEOF)
{
MessageBox(L"已经是最后一条记录!", L"提示", MB_ICONASTERISK);
return; //如果是最后一条记录则返回
}
m_pRecordset->MoveNext(); //向后移动一条记录
GetRecordContent();
}
void CDBOption::OnButtonPrev()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pRecordset == NULL) //如果记录集为空
return;
if (m_pRecordset->BOF)
{
MessageBox(L"已经是第一条记录!", L"提示", MB_ICONASTERISK);
return; //如果第一条记录则返回
}
m_pRecordset->MovePrevious();//向前移动一条记录
GetRecordContent();
}
void CDBOption::OnButtonWrite()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pConnection == NULL || m_pRecordset == NULL)
{
MessageBox(L"数据库未连接\r\n或数据集不存在", L"提示", MB_ICONASTERISK);
return;
}
UpdateData(true);
CString strSql;
strSql.Format(L"INSERT INTO Agent(ID, Agent_Name, Sex, Age) VALUES(%d, '%s', '%s', %d)", _ttoi(m_ID),m_Name,m_Sex,_ttoi(m_Age));
try
{
m_pConnection->Execute(_bstr_t(strSql), 0, adCmdText);
m_editLog.SetWindowText(L"写入成功!");
}
catch (_com_error e)
{
MessageBox(e.Description());
return;
}
}
void CDBOption::OnButtonDelete()
{
// TODO: 在此添加控件通知处理程序代码
if (m_pRecordset == NULL)
{
MessageBox(L"记录集不存在\r\n请先执行读取操作", L"提示", MB_ICONASTERISK);
return;
}
try
{
UpdateData(true);
bool key = false;
_variant_t vName;
m_pRecordset->Requery(NULL);
if (!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
while (true)
{
vName = m_pRecordset->GetCollect("Agent_Name");
if (m_Name == (LPCTSTR)(_bstr_t)(vName))
{
key = true;
break;
}
m_pRecordset->MoveNext();
if (m_pRecordset->adoEOF)
{
if (m_Name == (LPCTSTR)(_bstr_t)(vName))
{
key = true;
break;
}
else
{
MessageBox(L"该客户不存在\r\n无法进行删除\r\n请确认是否输入错误", L"提示", MB_ICONASTERISK);
break;
}
}
}
if (key)
{
m_pRecordset->Delete(adAffectCurrent);
m_pRecordset->Update();
CString sql;
m_pRecordset->Requery(NULL);
GetRecordContent();
m_editLog.SetWindowText(L"删除成功");
}
}
catch (_com_error e)
{
CString log;
log.Format(L"删除失败!\r\n原因:%s\r\n%s", e.ErrorMessage(), (LPCTSTR)e.Description());
MessageBox(log, L"提示", MB_ICONASTERISK);
}
}
#pragma once
#import "C:\Program Files\Common Files\System\ado\msado15.dll" \
no_namespace rename("EOF", "adoEOF")
// CDBOption 对话框
class CDBOption : public CDialogEx
{
DECLARE_DYNAMIC(CDBOption)
public:
CDBOption(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDBOption();
BOOL InitInstance();
void GetRecordContent();
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DB };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
afx_msg void OnButtonConnect();
// 状态信息
CEdit m_editLog;
// 客户编号
CString m_ID;
// 客户姓名
CString m_Name;
// 客户性别
CString m_Sex;
// 客户年龄
CString m_Age;
afx_msg void OnButtonRead();
afx_msg void OnButtonFirst();
afx_msg void OnButtonLast();
afx_msg void OnButtonNext();
afx_msg void OnButtonPrev();
afx_msg void OnButtonWrite();
afx_msg void OnButtonDelete();
};

// MainFrm.cpp: CMainFrame 类的实现
//
#include "stdafx.h"
#include "数据库操作.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
// CMainFrame 构造/析构
CMainFrame::CMainFrame() noexcept
{
// TODO: 在此添加成员初始化代码
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("未能创建工具栏\n");
return -1; // 未能创建
}
if (!m_wndStatusBar.Create(this))
{
TRACE0("未能创建状态栏\n");
return -1; // 未能创建
}
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
// TODO: 如果不需要可停靠工具栏,则删除这三行
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
return TRUE;
}
// CMainFrame 诊断
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
// CMainFrame 消息处理程序

// MainFrm.h: CMainFrame 类的接口
//
#pragma once
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame() noexcept;
// 特性
public:
// 操作
public:
// 重写
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// 实现
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // 控件条嵌入成员
CToolBar m_wndToolBar;
CStatusBar m_wndStatusBar;
// 生成的消息映射函数
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
};
B// Microsoft Visual C++ generated resource script.
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 My.rc 使用
//
#define IDD_ABOUTBOX 100
#define IDP_OLE_INIT_FAILED 100
#define IDR_MAINFRAME 128
#define IDR_MyTYPE 130
#define ID_WINDOW_MANAGER 131
#define IDD_DB 310
#define IDC_BUTTON_CONNECT 1000
#define IDC_EDIT_LOG 1001
#define IDC_BUTTON_READ 1003
#define IDC_EDIT_ID 1004
#define IDC_EDIT_NAME 1005
#define IDC_EDIT_SEX 1006
#define IDC_EDIT_AGE 1007
#define IDC_BUTTON_FIRST 1008
#define IDC_BUTTON_PREV 1009
#define IDC_BUTTON_NEXT 1010
#define IDC_BUTTON_LAST 1011
#define IDC_BUTTON_WRITE 1012
#define IDC_BUTTON1 1013
#define IDC_BUTTON_DELETE 1013
#define ID_32771 32771
#define ID_DB_MENU 32772
#define ID_ 32773
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 312
#define _APS_NEXT_COMMAND_VALUE 32774
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 310
#endif
#endif

// stdafx.cpp : 只包括标准包含文件的源文件
// 数据库操作.pch 将作为预编译标头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"

// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
// 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC 核心组件和标准组件
#include <afxext.h> // MFC 扩展
#include <afxdisp.h> // MFC 自动化类
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持
#include <afxcontrolbars.h>
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

// 数据库操作.cpp: 定义应用程序的类行为。
//
#include "stdafx.h"
#include "afxwinappex.h"
#include "afxdialogex.h"
#include "数据库操作.h"
#include "MainFrm.h"
#include<afxwin.h>
#include "ChildFrm.h"
#include "数据库操作Doc.h"
#include "数据库操作View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// C数据库操作App
BEGIN_MESSAGE_MAP(C数据库操作App, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &C数据库操作App::OnAppAbout)
// 基于文件的标准文档命令
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// 标准打印设置命令
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
ON_COMMAND(ID_DB_MENU,&C数据库操作App::OnDBOption)
END_MESSAGE_MAP()
// C数据库操作App 构造
C数据库操作App::C数据库操作App() noexcept
{
// 支持重新启动管理器
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
#ifdef _MANAGED
// 如果应用程序是利用公共语言运行时支持(/clr)构建的,则:
// 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。
// 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
#endif
// TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式
//为 CompanyName.ProductName.SubProduct.VersionInformation
SetAppID(_T("数据库操作.AppID.NoVersion"));
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}
// 唯一的 C数据库操作App 对象
C数据库操作App theApp;
// C数据库操作App 初始化
BOOL C数据库操作App::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。 文档模板
// 将用作文档、框架窗口和视图之间的连接
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_MyTYPE,
RUNTIME_CLASS(C数据库操作Doc),
RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架
RUNTIME_CLASS(C数据库操作View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 创建主 MDI 框架窗口
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。 如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 主窗口已初始化,因此显示它并对其进行更新
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
int C数据库操作App::ExitInstance()
{
//TODO: 处理可能已添加的附加资源
AfxOleTerm(FALSE);
return CWinApp::ExitInstance();
}
// C数据库操作App 消息处理程序
void C数据库操作App::OnDBOption()
{
CDBOption Dlg;
Dlg.DoModal();
}
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg() noexcept;
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// 用于运行对话框的应用程序命令
void C数据库操作App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// C数据库操作App 消息处理程序

// 数据库操作.h: 数据库操作 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
#include "DBOption.h"
#include<vector>
// C数据库操作App:
// 有关此类的实现,请参阅 数据库操作.cpp
//
class C数据库操作App : public CWinApp
{
public:
C数据库操作App() noexcept;
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
private:
// 存讲所有对话框的指针
afx_msg void OnAppAbout();
afx_msg void OnDBOption();
DECLARE_MESSAGE_MAP()
};
extern C数据库操作App theApp;
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{91C0A1AE-F84E-4004-9962-8CAB2B2A6D9D}</ProjectGuid>
<Keyword>MFCProj</Keyword>
<RootNamespace>数据库操作</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ChildFrm.h" />
<ClInclude Include="DBOption.h" />
<ClInclude Include="MainFrm.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="数据库操作.h" />
<ClInclude Include="数据库操作Doc.h" />
<ClInclude Include="数据库操作View.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ChildFrm.cpp" />
<ClCompile Include="DBOption.cpp" />
<ClCompile Include="MainFrm.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="数据库操作.cpp" />
<ClCompile Include="数据库操作Doc.cpp" />
<ClCompile Include="数据库操作View.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="My.rc" />
</ItemGroup>
<ItemGroup>
<None Include="res\My.rc2" />
</ItemGroup>
<ItemGroup>
<Image Include="res\Toolbar.bmp" />
<Image Include="res\数据库操作.ico" />
<Image Include="res\数据库操作Doc.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="数据库操作.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="MainFrm.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ChildFrm.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="数据库操作Doc.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="数据库操作View.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="DBOption.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="数据库操作.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="MainFrm.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ChildFrm.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="数据库操作Doc.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="数据库操作View.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="DBOption.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="My.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\My.rc2">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="res\数据库操作Doc.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\数据库操作.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Toolbar.bmp">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>
\ No newline at end of file

// 数据库操作Doc.cpp: C数据库操作Doc 类的实现
//
#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "数据库操作.h"
#endif
#include "数据库操作Doc.h"
#include <propkey.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// C数据库操作Doc
IMPLEMENT_DYNCREATE(C数据库操作Doc, CDocument)
BEGIN_MESSAGE_MAP(C数据库操作Doc, CDocument)
END_MESSAGE_MAP()
// C数据库操作Doc 构造/析构
C数据库操作Doc::C数据库操作Doc() noexcept
{
// TODO: 在此添加一次性构造代码
}
C数据库操作Doc::~C数据库操作Doc()
{
}
BOOL C数据库操作Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: 在此添加重新初始化代码
// (SDI 文档将重用该文档)
return TRUE;
}
// C数据库操作Doc 序列化
void C数据库操作Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: 在此添加存储代码
}
else
{
// TODO: 在此添加加载代码
}
}
#ifdef SHARED_HANDLERS
// 缩略图的支持
void C数据库操作Doc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)
{
// 修改此代码以绘制文档数据
dc.FillSolidRect(lprcBounds, RGB(255, 255, 255));
CString strText = _T("TODO: implement thumbnail drawing here");
LOGFONT lf;
CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
pDefaultGUIFont->GetLogFont(&lf);
lf.lfHeight = 36;
CFont fontDraw;
fontDraw.CreateFontIndirect(&lf);
CFont* pOldFont = dc.SelectObject(&fontDraw);
dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);
dc.SelectObject(pOldFont);
}
// 搜索处理程序的支持
void C数据库操作Doc::InitializeSearchContent()
{
CString strSearchContent;
// 从文档数据设置搜索内容。
// 内容部分应由“;”分隔
// 例如: strSearchContent = _T("point;rectangle;circle;ole object;");
SetSearchContent(strSearchContent);
}
void C数据库操作Doc::SetSearchContent(const CString& value)
{
if (value.IsEmpty())
{
RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);
}
else
{
CMFCFilterChunkValueImpl *pChunk = nullptr;
ATLTRY(pChunk = new CMFCFilterChunkValueImpl);
if (pChunk != nullptr)
{
pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);
SetChunkValue(pChunk);
}
}
}
#endif // SHARED_HANDLERS
// C数据库操作Doc 诊断
#ifdef _DEBUG
void C数据库操作Doc::AssertValid() const
{
CDocument::AssertValid();
}
void C数据库操作Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// C数据库操作Doc 命令

// 数据库操作Doc.h: C数据库操作Doc 类的接口
//
#pragma once
class C数据库操作Doc : public CDocument
{
protected: // 仅从序列化创建
C数据库操作Doc() noexcept;
DECLARE_DYNCREATE(C数据库操作Doc)
// 特性
public:
// 操作
public:
// 重写
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
#ifdef SHARED_HANDLERS
virtual void InitializeSearchContent();
virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS
// 实现
public:
virtual ~C数据库操作Doc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
#ifdef SHARED_HANDLERS
// 用于为搜索处理程序设置搜索内容的 Helper 函数
void SetSearchContent(const CString& value);
#endif // SHARED_HANDLERS
};

// 数据库操作View.cpp: C数据库操作View 类的实现
//
#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "数据库操作.h"
#endif
#include "数据库操作Doc.h"
#include "数据库操作View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// C数据库操作View
IMPLEMENT_DYNCREATE(C数据库操作View, CView)
BEGIN_MESSAGE_MAP(C数据库操作View, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// C数据库操作View 构造/析构
C数据库操作View::C数据库操作View() noexcept
{
// TODO: 在此处添加构造代码
}
C数据库操作View::~C数据库操作View()
{
}
BOOL C数据库操作View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
return CView::PreCreateWindow(cs);
}
// C数据库操作View 绘图
void C数据库操作View::OnDraw(CDC* /*pDC*/)
{
C数据库操作Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此处为本机数据添加绘制代码
}
// C数据库操作View 打印
BOOL C数据库操作View::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void C数据库操作View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加额外的打印前进行的初始化过程
}
void C数据库操作View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加打印后进行的清理过程
}
// C数据库操作View 诊断
#ifdef _DEBUG
void C数据库操作View::AssertValid() const
{
CView::AssertValid();
}
void C数据库操作View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
C数据库操作Doc* C数据库操作View::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(C数据库操作Doc)));
return (C数据库操作Doc*)m_pDocument;
}
#endif //_DEBUG
// C数据库操作View 消息处理程序

// 数据库操作View.h: C数据库操作View 类的接口
//
#pragma once
class C数据库操作View : public CView
{
protected: // 仅从序列化创建
C数据库操作View() noexcept;
DECLARE_DYNCREATE(C数据库操作View)
// 特性
public:
C数据库操作Doc* GetDocument() const;
// 操作
public:
// 重写
public:
virtual void OnDraw(CDC* pDC); // 重写以绘制该视图
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// 实现
public:
virtual ~C数据库操作View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // 数据库操作View.cpp 中的调试版本
inline C数据库操作Doc* C数据库操作View::GetDocument() const
{ return reinterpret_cast<C数据库操作Doc*>(m_pDocument); }
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册