int playSound(char *buf, int size) { if (!_use_mocks) return _playSound(buf, size); else return _playMock(buf, size); }
BOOL CLotteryDlg::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if (pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_RBUTTONDOWN || (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_SPACE)) { static long ticktock = GetTickCount(); //响应左键,右键,空格键 if (GetTickCount() - ticktock > 1000) { m_bRollTimer = m_bRollTimer? FALSE : TRUE; if (m_bRollTimer) { if (m_bRealStop) { _stopSound(); _beginNextRing();//开始一轮的抽奖 m_bFirstFlash = FALSE; SetTimer(1, TIMER1, NULL); _playSound(LOTTERYING, true); } else m_bRollTimer = FALSE; } else { _stopSound(); _playSound(STOPPING, false); KillTimer(1); m_StopTime = TIMER2; SetTimer(2, m_StopTime, NULL); } InvalidateRect(NULL); ticktock = GetTickCount(); } } return CDialog::PreTranslateMessage(pMsg); }
void CLotteryDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nIDEvent == 1) { //计算下一个图形显示的信息 m_bRealStop = FALSE;//设置关 //_calcRenderInfo();//计算参与者手机号的显示信息 calcNextPicInfoOfRing();//计算参与者图片的显示信息 InvalidateRect(m_RenderRect); PostMessage(WM_PAINT); } else if (nIDEvent == 2) { //计算下一个图形显示的信息 static int _count = 0;//这里最大允许循环次数 int times[8] = {100, 200, 300, 300, 400, 450, 500, 50}; int stoptime = times[_count]; CString str; str.Format(L"%d\n",stoptime); OutputDebugString(str); if (_count < sizeof(times)/sizeof(times[0])-1)//569*1.5=853.5 { ++_count; SetTimer(2, stoptime, NULL); //_calcRenderInfo();//算参与者手机号的显示信息 calcNextPicInfoOfRing();//计算参与者图片的显示信息 InvalidateRect(NULL); PostMessage(WM_PAINT); OutputDebugString(L"停止ing\n"); } else { _count = 0; KillTimer(2); OutputDebugString(L"停止\n"); m_bRealStop = TRUE;//设置开 _finishRing(); InvalidateRect(NULL); RedrawWindow(); _getNextListOfPartnerNo(); _playSound(BEGIN, true); } } CDialog::OnTimer(nIDEvent); }
BOOL CLotteryDlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 fullScreen(); InitLottery(); m_bRollTimer = FALSE; _playSound(BEGIN, true); SetFocus(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }