제목 그대로 키보드로 마우스 커서를 움직이는 코드입니다. CView에서 OnKeyDown 함수를 다음과 같이 고치면 됩니다. void CCGhostView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CPoint ptCurPos; // 현재 커서의 위치 if(::GetCursorPos(&ptCurPos)) { // 현재 커서 위치를 얻는다. (스크린 좌표) switch(nChar) { // 키값(nChar)에 따라 새로운 커서 위치 설정 case VK_LEFT : ptCurPos.x -= 30; ::SetCursorPos(ptCurPos.x, ptCurPos.y); break; case VK_RIGHT : ptCurPos.x += 30; ::SetCursorPos(ptCurPos.x, ptCurPos.y); break; case VK_UP : ptCurPos.y -= 30; ::SetCursorPos(ptCurPos.x, ptCurPos.y);
break; case VK_DOWN : ptCurPos.y += 30; ::SetCursorPos(ptCurPos.x, ptCurPos.y); break; } } CView::OnKeyDown(nChar, nRepCnt, nFlags); } Tags: 마우스 마우스 이벤트 윈도우즈 키보드 키보드 이벤트
|