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

📄 calculatethread.cpp

📁 VisualC高级编程技术精粹.rar
💻 CPP
字号:
// CalculateThread.cpp : implementation file
//

#include "stdafx.h"
#include "ThreadCommunication.h"
#include "CalculateThread.h"
#include "ThreadCommunicationDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCalculateThread

IMPLEMENT_DYNCREATE(CCalculateThread, CWinThread)

CCalculateThread::CCalculateThread()
{
}

CCalculateThread::~CCalculateThread()
{
}

BOOL CCalculateThread::InitInstance()
{
	// TODO:  perform and per-thread initialization here
	return TRUE;
}

int CCalculateThread::ExitInstance()
{
	// TODO:  perform any per-thread cleanup here
	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CCalculateThread, CWinThread)
	//{{AFX_MSG_MAP(CCalculateThread)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_THREAD_MESSAGE(WM_CALCULATE,OnCalculate)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCalculateThread message handlers
LONG CCalculateThread::OnCalculate(UINT wParam,LONG lParam)
{
	int nLastOperand = 0;
	for (int i = 0; i <= (int)wParam; i++)
	{
		nLastOperand = nLastOperand + i;
	}

	Sleep(200);
    ::PostMessage((HWND)(GetMainWnd()->GetSafeHwnd()),
		                 WM_DISPLAY,
						 nLastOperand,
						 NULL);

	return 0;
}

⌨️ 快捷键说明

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