|
-
July 16th, 2011, 05:52 AM
#1
Virtual Key Codes
Hi, here is my windows procedure:
LRESULT CALLBACK MessageProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int X = 250;
static int Y = 250;
HINSTANCE hInstance;
hInstance = LoadLibrary (TEXT("Application01.exe"));
switch(message)
{
case WM_CREATE:
int MessageBoxID;
MessageBoxID = MessageBox(hWnd, TEXT(" Are ya ready kids?"), TEXT("Are ya ready kids?"),
MB_ICONQUESTION | MB_YESNO);
if (MessageBoxID == IDNO)
{
PostQuitMessage(0);
}
if (MessageBoxID == IDYES)
{
UpdateWindow(hWnd);
}
return FALSE;
case WM_PAINT:
HICON hIcon;
hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
HDC handleDeviceContext;
PAINTSTRUCT PaintSt;
handleDeviceContext = BeginPaint(hWnd, &PaintSt);
DrawIcon(handleDeviceContext, X, Y, hIcon);
EndPaint(hWnd, &PaintSt);
break;
case WM_KEYDOWN:
switch(wParam)
case VK_LEFT:
{
X -= 5;
InvalidateRect(hWnd, NULL, TRUE);
break;
}
case VK_RIGHT:
{
X += 5;
InvalidateRect(hWnd, NULL, TRUE);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
The X and Y variables are integers which are used here:
DrawIcon(handleDeviceContext, X, Y, hIcon);
So the X and Y are the location of the icon.
The problem I am having is that when i press the left arrow key, nothing happens, and when i press the right arrow key it DOES go right, but it also goes right when i press the up and down kep :S
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|