📄 bookman.cpp
字号:
// bookMan.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "bookMan.h"
#include "MainFrm.h"
#include "bookManDoc.h"
#include "bookManView.h"
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBookManApp
BEGIN_MESSAGE_MAP(CBookManApp, CWinApp)
//{{AFX_MSG_MAP(CBookManApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBookManApp construction
CBookManApp::CBookManApp()
{
m_bLogined=FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CBookManApp object
CBookManApp theApp;
_ConnectionPtr pConn;
/////////////////////////////////////////////////////////////////////////////
// CBookManApp initialization
BOOL CBookManApp::InitInstance()
{
::CoInitialize(NULL);
try{
TESTHR(pConn.CreateInstance("ADODB.Connection"));
pConn->Open("Provider=microsoft.jet.oledb.4.0;data source=book.mdb;","","",adModeUnknown);
}
catch(_com_error &e){
DisplayAdoError(e);
return FALSE;
}
catch(...){
AfxMessageBox("打开数据库时出错:未知错误!");
return FALSE;
}
\ {\ CCommandLineInfo cmdInfo;\ ParseCommandLine(cmdInfo);\\ CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);\ }
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("爱盟工作室(A.U.C)书籍管理系统"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CBookManDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CBookManView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
(AfxGetMainWnd())->SetWindowText("書籍管理系統");
m_pMainWnd->UpdateWindow();
((CBookManView *)((CMainFrame *)AfxGetMainWnd())->GetActiveView())->m_MainPage.Invalidate();
m_animateStatus.Create(IDR_AVI_STATUS,&((CMainFrame *)AfxGetMainWnd())->m_wndStatusBar,1);
return TRUE;
}
BOOL CBookManApp::PreTranslateMessage(MSG* pMsg)
{
// CG: The following lines were added by the Splash Screen component. if (CSplashWnd::PreTranslateAppMessage(pMsg)) return TRUE; return CWinApp::PreTranslateMessage(pMsg);
}
int CBookManApp::ExitInstance()
{
if(pConn->GetState()==adStateOpen)
pConn->Close();
pConn.Release();
::CoUninitialize();
return CWinApp::ExitInstance();
}
void DisplayAdoError(_com_error &e)
{
CString str;
str.Format("错误:%s\r\n描述:%s",(char *)e.Source(),(char *)e.Description());
::MessageBox(NULL,str,"打开数据库错误",MB_OK|MB_ICONWARNING);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -