winapp.cpp

来自「使非MFC窗口程序的窗口回调过程成为C++类的成员函数。」· C++ 代码 · 共 62 行

CPP
62
字号
#include "stdafx.h"
#include "winapp.h"
#include "dialog.h"
#include "formdlg.h"


CWinApp		g_theApp;


int APIENTRY _tWinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine,
	int nShowCmd)
{
	g_hInstance = hInstance;
	g_theApp.m_hInst = hInstance;
	if(g_theApp.InitInstance())
	{
		return g_theApp.Run();
	}
	return g_theApp.ExitInstance();
}


CWinApp::CWinApp() : m_hInst(NULL), m_nRetCode(0)
{
}


CWinApp::~CWinApp()
{
}


bool CWinApp::InitInstance()
{
	CFormDlg	dlg;
	dlg.DoModal();
	return false;
}


int CWinApp::Run()
{
	MSG		msg;

	while(GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	m_nRetCode = msg.wParam;
	return ExitInstance();
}


int CWinApp::ExitInstance()
{
	return m_nRetCode;
}

⌨️ 快捷键说明

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