先设置一个计时器:两个键同时按下或者其中任意一个按下完全能够响应
VOID CALLBACK TimerProc (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
{
HDC hdc=GetDC(hwnd);
static int x=0,y=0;
// 得到按键状态
short s1=GetKeyState(VK_UP); // ↑
short s2=GetKeyState(VK_LEFT); // ←
// 向上箭头按下
if(HIWORD(s1))
//随便画点什么,以便检测,单按连续显示虚线
{ MoveToEx(hdc,(x+=5),(y+=5),NULL); LineTo (hdc,(x+=25),(y+=25));}
// 向左箭头按下
if(HIWORD(s2))
// 这个没用+=,单按会只在原地显示一个折线图片,同时按才能移动显示
{ LineTo(hdc,x+10,y+20); LineTo(hdc,x+10,y-20);}
// 同时按下弹了消息框
if(HIWORD(s1)&&HIWORD(s2))
::MessageBox(hwnd,TEXT(""),TEXT(""),0);
}
