soundthread.cpp

来自「vc++6.0开发网络典型应用实例导航 1. 本光盘提供了本书中所有的实例源」· C++ 代码 · 共 56 行

CPP
56
字号
// SoundThread.cpp : implementation file
//

#include "stdafx.h"
#include "Netmsg.h"
#include "SoundThread.h"
#include <mmsystem.h>

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

//This thread plays sounds without holding up the main program

IMPLEMENT_DYNCREATE(CSoundThread, CWinThread)

CSoundThread::CSoundThread(int sound)
{
	nSound = sound;
}

CSoundThread::~CSoundThread()
{
}

BOOL CSoundThread::InitInstance()
{
	switch (nSound)
	{
	case 1:
		break;
	case 2:
		sndPlaySound("alert2.wav", SND_ASYNC);
		break;
	}
	PostThreadMessage(WM_QUIT, 0, 0);
	return TRUE;
}

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

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

/////////////////////////////////////////////////////////////////////////////
// CSoundThread message handlers

⌨️ 快捷键说明

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