Ok then... Where are you telling me to put "return 0;"???
Printable View
Ok then... Where are you telling me to put "return 0;"???
Right after your processing code for VK_LEFT/VK_RIGHT of WM_KEYDOWN message.
Thanks :)
The left and right arrow key is now working as it should, although when i press a key such as 'S' or any other key which I have not defined code for makes my icon move right.
Show your actual code.
Code:case WM_KEYDOWN:
switch(wParam)
case VK_LEFT:
{
X -= 5;
InvalidateRect(hWnd, NULL, TRUE);
return 0;
}
case VK_RIGHT:
{
X += 5;
InvalidateRect(hWnd, NULL, TRUE);
return 0;
}
break;
Try:Besides, the line, hInstance = LoadLibrary (TEXT("Application01.exe"));, is run every time a message arrives, which might occur several dozen of times per seconds. That line might take a lot of time and resources. I would advise you to load that library only in WM_CREATE, and declare hInstance as a static variable.Code: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;
}
}
return(0);
break;
Actually, GetModuleHandle(NULL) would be enough, as long as it is about getting main .exe instance handle.
I'm almost sure it is, as nobody loads external .exe to the process. :)