📄 indexeditor.cpp
字号:
// IndexEditor.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "IndexEditor.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "IndexEditorDoc.h"
#include "IndexEditorView.h"
#include "IpFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CIndexEditorApp
BEGIN_MESSAGE_MAP(CIndexEditorApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
// CIndexEditorApp construction
CIndexEditorApp::CIndexEditorApp() :
CBCGPWorkspace (TRUE /* m_bResourceSmartUpdate */)
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CIndexEditorApp object
CIndexEditorApp theApp;
static const CLSID clsid =
// {BEEDC1CD-4FAD-429d-A498-75581B951B29}
{ 0xbeedc1cd, 0x4fad, 0x429d, { 0xa4, 0x98, 0x75, 0x58, 0x1b, 0x95, 0x1b, 0x29 } };
// CIndexEditorApp initialization
BOOL CIndexEditorApp::InitInstance()
{
CoInitialize(NULL);
if(FAILED(m_cpIndexsWorkspace.CreateInstance(CLSID_IndexsWorkspace2)))
return FALSE;
// InitCommonControls() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
InitCommonControls();
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
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
// 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("Index System Edit Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
SetRegistryBase (_T("Settings"));
// Initialize all Managers for usage. They are automatically constructed
// if not yet present
InitContextMenuManager();
InitKeyboardManager();
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_IndexEditorTYPE,
RUNTIME_CLASS(CIndexEditorDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CIndexEditorView));
if (!pDocTemplate)
return FALSE;
pDocTemplate->SetServerInfo(
IDR_IndexEditorTYPE_SRVR_EMB, IDR_IndexEditorTYPE_SRVR_IP,
RUNTIME_CLASS(CInPlaceFrame));
AddDocTemplate(pDocTemplate);
// 将 COleTemplateServer 连接到文档模板
// COleTemplateServer 通过使用
// 文档模板中指定的信息来为
// 请求 OLE 容器创建新文档
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
// 将所有的 OLE 服务器工厂注册为正在运行。这将启用
// OLE 库以从其他应用程序中创建对象
COleTemplateServer::RegisterAll();
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// 不显示主窗口
return TRUE;
}
// 使用 /Unregserver 或 /Unregister 开关启动应用程序。 注销
// 类型库。其他注销操作在 ProcessShellCommand() 中发生。
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
UnregisterShellFileTypes();
m_server.UpdateRegistry(OAT_INPLACE_SERVER, NULL, NULL, FALSE);
}
// 应用程序是以独立方式或用其他开关(如 /Register
// 或 /Regserver)启动的。更新注册表项,包括类型库。
else
{
m_server.UpdateRegistry(OAT_INPLACE_SERVER);
}
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
pMainFrame->UpdateWindow();
return TRUE;
}
// CIndexEditorApp message handlers
int CIndexEditorApp::ExitInstance()
{
m_cpIndexsWorkspace.Release();
BCGCBProCleanUp();
CoUninitialize();
return CWinApp::ExitInstance();
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
CBCGPURLLinkButton m_btnURL;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMPANY_URL, m_btnURL);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// App command to run the dialog
void CIndexEditorApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CIndexEditorApp message handlers
void CIndexEditorApp::PreLoadState ()
{
GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU);
// TODO: add another context menus here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -