//光标消息
BOOL CPasswordKeyboard::OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT uMessage)
{
	//获取光标
	CPoint MousePoint;
	GetCursorPos(&MousePoint);
	ScreenToClient(&MousePoint);

	//更新位置
	WORD wHoverRow=m_wHoverRow;
	WORD wHoverLine=m_wHoverLine;
	SetCurrentStation(MousePoint);

	//更新界面
	if ((m_wHoverRow!=wHoverRow)||(m_wHoverLine!=wHoverLine))
	{
		RedrawWindow(NULL,NULL,RDW_FRAME|RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASENOW);
	}

	//设置光标
	if ((m_wHoverRow!=INVALID_WORD)&&(m_wHoverLine!=INVALID_WORD))
	{
		SetCursor(LoadCursor(GetModuleHandle(SHARE_CONTROL_DLL_NAME),MAKEINTRESOURCE(IDC_HAND_CUR)));
		return true;
	}

	return __super::OnSetCursor(pWnd,nHitTest,uMessage);
}
Exemple #2
0
int
MythPianoService::service_heartbeat() {

	if(debug)
		printf("Determining current song...\n");

	rlen = sprintf(request, "status\n");
	SendPianodRequest(204);
 
	/* parse current song */
	if(response->back().code == 204) {

		for(int x = 0; x < response->size() - 1; x++) {
			MythPianoResponse r = response->at(x);

			if(response->at(x).code == 203) {
				map<string, string> song = PullOutSong(x + 1);

				if(song.size() != 0) {

					if(debug)
						cout<<"Setting current song: " << song["Title"] << endl;

					if(!current_song.size() || (current_song["Title"] != song["Title"])) {
						current_song = song; 
						song_changed = 1;
					} 
					else {
						current_song["Rating"] = song["Rating"];
					}

				}
			}
		}
	} 
	else {
		BroadcastMessage("Failed to get current song(2)!\n");
		return -1;
	}

	if(debug)
		printf("Checking for status....current_station %d \n", current_station);
		
	CheckForResponse(101, 102, 103, 104, 1);
	MythPianoResponse r = response->back();

	if(r.code == 101 || r.code == 102 || r.code == 104) {
		size_t pos = r.value.find("/");
		played = r.value.substr(0, pos);
		string rest = r.value.substr(pos + 1);
		pos = rest.find("/");
		duration = rest.substr(0, pos);

		if(current_station == -1) {
			pos = r.value.find(" ");
			rest = r.value.substr(pos + 1);
			pos = rest.find(" ");
			rest = rest.substr(pos + 1);
			pos = rest.find(" ");
			current_station_name = rest.substr(pos + 1);
			SetCurrentStation(QString(current_station_name.c_str()));

			if(debug)
				cout << "current station is " + current_station_name << " " << current_station << endl;
		}
	} 
	else if(r.code == 103) {
	if(debug)
		printf("pianod is stopped\n");
	}
	else {
		BroadcastMessage("Failed to get duration of current song\n");
		return -1;
	}

 return 0; 
}
//鼠标消息
VOID CPasswordKeyboard::OnLButtonUp(UINT nFlags, CPoint Point)
{
	__super::OnLButtonUp(nFlags,Point);

	//取消捕获
	if (m_bMouseDown==true)
	{
		//取消捕获
		ReleaseCapture();

		//设置变量
		m_bMouseDown=false;

		//获取光标
		CPoint MousePoint;
		GetCursorPos(&MousePoint);
		ScreenToClient(&MousePoint);

		//更新位置
		WORD wHoverRow=m_wHoverRow;
		WORD wHoverLine=m_wHoverLine;
		SetCurrentStation(MousePoint);

		//点击处理
		if ((m_wHoverRow==wHoverRow)&&(m_wHoverLine==wHoverLine))
		{
			//关闭按钮
			if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_CLOSE_KEY))
			{
				//设置焦点
				CONTAINING_RECORD(this,CPasswordControl,m_PasswordKeyboard)->m_edPassword.SetFocus();

				//销毁窗口
				DestroyWindow();

				return;
			}

			//虚拟编码
			WORD wViraulCode=GetVirualKeyCode(m_wHoverLine,m_wHoverRow);

			//按钮处理
			switch (wViraulCode)
			{
			case VK_SHIFT:		//切换按钮
				{
					//设置变量
					m_bShiftStatus=!m_bShiftStatus;

					break;
				}
			case VK_CAPITAL:	//大写按钮
				{
					//变量定义
					INPUT Input[2];
					ZeroMemory(Input,sizeof(Input));

					//设置变量
					Input[1].ki.dwFlags=KEYEVENTF_KEYUP;   
					Input[0].type=Input[1].type=INPUT_KEYBOARD;
					Input[0].ki.wVk=Input[1].ki.wVk=wViraulCode;

					//模拟输入
					SendInput(CountArray(Input),Input,sizeof(INPUT));

					break;
				}
			default:			//默认按钮
				{
					//设置变量
					m_bShiftStatus=(GetKeyState(VK_SHIFT)&0xF0)>0;

					//发送消息
					CPasswordControl * pPasswordControl=CONTAINING_RECORD(this,CPasswordControl,m_PasswordKeyboard);
					if (pPasswordControl!=NULL) pPasswordControl->m_edPassword.SendMessage(WM_CHAR,wViraulCode,0L);

					break;
				}
			}
		}

		//更新界面
		RedrawWindow(NULL,NULL,RDW_FRAME|RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASENOW);
	}

	return;
}