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

📄 appthread.cpp

📁 硬件的操作系统语言
💻 CPP
字号:
// AppThread.cpp : implementation file
//

#include "stdafx.h"
#include "sameproc.h"
#include "AppThread.h"
#include "MainFrm.h"

#include "AppWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAppThread

IMPLEMENT_DYNCREATE(CAppThread, CWinThread)

CAppThread::CAppThread()
{
}

CAppThread::~CAppThread()
{
}

BOOL CAppThread::InitInstance()
{
	InterlockedIncrement(&s_nInstances);  //实例数加1
	
	//创建MDI主窗口
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	
	CCommandLineInfo cmdInfo;
	

	// Dispatch commands specified on the command line
	if (!AfxGetApp()->ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow( SW_SHOWNORMAL/* m_nCmdShow */);
	pMainFrame->UpdateWindow();

	return TRUE;
}

int CAppThread::ExitInstance()
{
	InterlockedDecrement(&s_nInstances);

	if (s_nInstances == 0) //没有实例运行
	{
		AfxGetApp()->m_pMainWnd->PostMessage(WM_CLOSE);	
	}

	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CAppThread, CWinThread)
	//{{AFX_MSG_MAP(CAppThread)
	ON_COMMAND(ID_APP_EXIT, OnAppExit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//初始化静态数据成员
long CAppThread::s_nInstances;



/////////////////////////////////////////////////////////////////////////////
// CAppThread message handlers

void CAppThread::OnAppExit() 
{
	// TODO: Add your command handler code here
	ASSERT(m_pMainWnd != NULL);
	m_pMainWnd->SendMessage(WM_CLOSE);

}

⌨️ 快捷键说明

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