⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmvc.cpp

📁 本人买的<<VC++项目开发实例>>源代码配套光盘.
💻 CPP
字号:
// WMVC.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "WMVC.h"
#include "WMSheet.h"		//for CWMSheet
#include "WMPropDlg.h"		//for CWMPropDlg
#include "SetupPropDlg.h"	//for CSetupPropDlg
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "Configration.h"
/////////////////////////////////////////////////////////////////////////////
// CWMVCApp

BEGIN_MESSAGE_MAP(CWMVCApp, CWinApp)
	//{{AFX_MSG_MAP(CWMVCApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWMVCApp construction

CWMVCApp::CWMVCApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CWMVCApp object

CWMVCApp theApp;

//配置信息
CConfigration config;
//创建互斥的Mutex对象,防止应用系统多次启动。
#include <afxmt.h>	//for CMutex
CMutex mutex(FALSE, "_WMVC_MUTEX_");
/////////////////////////////////////////////////////////////////////////////
// CWMVCApp initialization

BOOL CWMVCApp::InitInstance()
{
	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

	//
	// 查看是否有另外一份copy在运行。
	//
	if (!mutex.Lock(20))
	{
		AfxMessageBox("系统不能多次启动,请使用快捷键激活!", MB_OK | MB_ICONINFORMATION);
		return FALSE ;
	}
	//
	//加载配置信息
	//
	config.Load();

	//
	// 创建两个属性页
	//
	CWMPropDlg dlgWM;
	CSetupPropDlg dlgSetup;
	//CWMVCDlg dlg;
	//
	// 创建PropertySheet
	//
	CWMSheet dlgSheet(AFX_IDS_APP_TITLE);
	dlgSheet.CPropertySheet::AddPage(&dlgWM);
	dlgSheet.CPropertySheet::AddPage(&dlgSetup);
	//dlgSheet.ModifyStyle(0, WS_MINIMIZEBOX | WS_SYSMENU);

	m_pMainWnd = &dlgSheet;
	int nResponse = dlgSheet.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

CString CWMVCApp::GetAppDir()
{
	char szFilePath[MAX_PATH] = {0};
	char szDrive[_MAX_DRIVE]={0}, szDir[_MAX_DIR]={0}
		, szFName[_MAX_FNAME]={0}, szExt[_MAX_EXT]={0};
	
	GetModuleFileName(AfxGetInstanceHandle(), szFilePath, sizeof(szFilePath));
	_splitpath(szFilePath, szDrive, szDir, NULL, NULL);
	
	//取得应用程序所在路径
	CString strAppFilePath;
	strAppFilePath = szDrive;
	strAppFilePath += szDir;
	
	return strAppFilePath;
}

int CWMVCApp::ExitInstance() 
{
	config.Save();
	mutex.Unlock();
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -