-
July 17th, 2011, 10:16 AM
#16
Re: Virtual Key Codes
Ok then... Where are you telling me to put "return 0;"???
-
July 17th, 2011, 10:20 AM
#17
Re: Virtual Key Codes
Right after your processing code for VK_LEFT/VK_RIGHT of WM_KEYDOWN message.
Victor Nijegorodov
-
July 17th, 2011, 01:02 PM
#18
Re: Virtual Key Codes
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.
-
July 17th, 2011, 01:04 PM
#19
Re: Virtual Key Codes
Victor Nijegorodov
-
July 17th, 2011, 01:12 PM
#20
Re: Virtual Key Codes
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;
-
July 18th, 2011, 04:55 AM
#21
Re: Virtual Key Codes
Try:
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;
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.
Last edited by olivthill2; July 18th, 2011 at 05:01 AM.
-
July 20th, 2011, 01:29 AM
#22
Re: Virtual Key Codes
Actually, GetModuleHandle(NULL) would be enough, as long as it is about getting main .exe instance handle.
Best regards,
Igor
-
July 20th, 2011, 01:25 PM
#23
Re: Virtual Key Codes
Originally Posted by Igor Vartanov
Actually, GetModuleHandle(NULL) would be enough, as long as it is about getting main .exe instance handle.
If it is, the instance handle is passed into WinMain(), and is typically saved in a global variable.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
July 20th, 2011, 01:34 PM
#24
Re: Virtual Key Codes
I'm almost sure it is, as nobody loads external .exe to the process.
Best regards,
Igor
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
|