?? appthread.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); //實例數(shù)加1
//創(chuàng)建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()
//初始化靜態(tài)數(shù)據(jù)成員
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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -