dbexp.cpp
来自「本人买的<<VC++项目开发实例>>源代码配套光盘.」· C++ 代码 · 共 306 行
CPP
306 行
// DBExp.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "DBExp.h"
#include "MainFrm.h"
#include "VicDoc.h"
#include "AliasView.h"
#include <initguid.h>
#include "DBExp_i.c"
#include "FrmViewContainer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVicApp
BEGIN_MESSAGE_MAP(CVicApp, CWinApp)
//{{AFX_MSG_MAP(CVicApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_HOWTODO, OnHowtodo)
ON_COMMAND(ID_HELP, OnHelp)
ON_COMMAND(ID_HELP_USING, OnHelpUsing)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CVicApp construction
//##ModelId=3C37413F0326
CVicApp::CVicApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CVicApp object
CVicApp theApp;
// This identifier was generated to be statistically unique for your app.
// You may change it if you prefer to choose a specific identifier.
// {0C6B7FC1-C393-4F12-9EB6-911715C9097E}
static const CLSID clsid =
{ 0xc6b7fc1, 0xc393, 0x4f12, { 0x9e, 0xb6, 0x91, 0x17, 0x15, 0xc9, 0x9, 0x7e } };
/////////////////////////////////////////////////////////////////////////////
// CVicApp initialization
//##ModelId=3C37413F0330
BOOL CVicApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
if (!InitATL())
return FALSE;
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CVicDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CAliasView));
AddDocTemplate(pDocTemplate);
// Connect the COleTemplateServer to the document template.
// The COleTemplateServer creates new documents on behalf
// of requesting OLE containers by using information
// specified in the document template.
m_server.ConnectTemplate(clsid, pDocTemplate, TRUE);
// Note: SDI applications register server objects only if /Embedding
// or /Automation is present on the command line.
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
_Module.UpdateRegistryFromResource(IDR_DBEXP, TRUE);
_Module.RegisterServer(TRUE);
// Check to see if launched as OLE server
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// Register all OLE server (factories) as running. This enables the
// OLE libraries to create objects from other applications.
COleTemplateServer::RegisterAll();
_Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE);
// Application was run with /Embedding or /Automation. Don't show the
// main window in this case.
return TRUE;
}
// When a server application is launched stand-alone, it is a good idea
// to update the system registry in case it has been damaged.
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
COleObjectFactory::UpdateRegistryAll();
// 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);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetWindowText("DBExplorer v1.0");
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
//##ModelId=3C3741400328
class CAboutDlg : public CDialog
{
public:
//##ModelId=3C374140035A
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
//##ModelId=3C374140035B
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//##ModelId=3C374140035A
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
//##ModelId=3C374140035B
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
//##ModelId=3C37413F03D1
void CVicApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CVicApp message handlers
//##ModelId=3C41296201BD
const char * CVicApp::GetAppPath()
{
static char ExeFilePath[MAX_PATH] = {0};
VERIFY( 0 != GetModuleFileName(m_hInstance, ExeFilePath, sizeof(ExeFilePath)));
static char drive[_MAX_DRIVE];
static char dir[_MAX_DIR];
static char fname[_MAX_FNAME];
static char ext[_MAX_EXT];
_splitpath(ExeFilePath, drive, dir, fname, ext);
wsprintf(ExeFilePath, "%s%s", drive, dir);
return ExeFilePath;
}
//##ModelId=3C412963036D
void CVicApp::OnHowtodo()
{
// TODO: Add your command handler code here
AfxMessageBox("教导:做事情要有计划!");
}
CDBExpModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
END_OBJECT_MAP()
//##ModelId=3C5350AF025B
LONG CDBExpModule::Unlock()
{
AfxOleUnlockApp();
return 0;
}
//##ModelId=3C5350AF0283
LONG CDBExpModule::Lock()
{
AfxOleLockApp();
return 1;
}
//##ModelId=3C5350B30207
int CVicApp::ExitInstance()
{
if (m_bATLInited)
{
_Module.RevokeClassObjects();
_Module.Term();
}
return CWinApp::ExitInstance();
}
//##ModelId=3C5350B4003B
BOOL CVicApp::InitATL()
{
m_bATLInited = TRUE;
_Module.Init(ObjectMap, AfxGetInstanceHandle());
_Module.dwThreadID = GetCurrentThreadId();
return TRUE;
}
void CVicApp::OnHelp()
{
WinHelp(1000);
}
void CVicApp::OnHelpUsing()
{
// TODO: Add your command handler code here
WinHelp(0, HELP_HELPONHELP);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?