scrplay.cpp

来自「源代码演示了在Windows下角色扮演游戏的制作过程」· C++ 代码 · 共 64 行

CPP
64
字号
//
// Script Player Application
//
//		Copyright (c) 2000-2002 Chihiro.SAKAMOTO (HyperWorks)
//
#include "StdAfx.h"
#include "ScrPlay.h"
#include "resource.h"

//
// 应用程序的实体(Instance)
//
CScrPlayApp	theApp;

//
// 构造函数
//
CScrPlayApp::CScrPlayApp()
{
	hMutex = 0;
}

//
// 析构函数
//
CScrPlayApp::~CScrPlayApp()
{
	if (hMutex)
		::CloseHandle(hMutex);
}

//
// 应用程序初始化
//
BOOL CScrPlayApp::InitInstance()
{
	// 防止应用程序多重启动
	if ((hMutex = ::CreateMutex(NULL, FALSE, ApplicationName "_Running")) == NULL)
		return FALSE;

	DWORD	Ret = ::WaitForSingleObject(hMutex, 0);
	if (Ret == WAIT_TIMEOUT || Ret == WAIT_FAILED)
		return FALSE;

	// 显示模式若不是真彩模式则不能启动
	HDC		dc = GetDC(0);
	int		nbits = GetDeviceCaps(dc, BITSPIXEL);
	ReleaseDC(0, dc);

	if (nbits < 15) {
		::MessageBox(0, "不能在256色以下模式启动。\n请更改显示模式。",
			ApplicationTitle, MB_ICONSTOP|MB_OK);
		return FALSE;
	}

	// 建立主窗口
	if (!MainWin.Create(this, ApplicationTitle, LoadMenu(IDC_APPMENU)))
		return FALSE;

	MainWnd = &MainWin;

	return TRUE;
}

⌨️ 快捷键说明

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