?
Solved

VK_SPACE

Posted on 2007-04-09
3
Medium Priority
?
1,939 Views
Last Modified: 2013-12-03
Hi,

I want to make some hotkeys for my application. I want to bind the space bar. - but space bar doesn't have an ascii code, it has a virtual key code. Is that virtual key code value consistent for all keyboards? I'm trying something like:

    // VK_SPACE on my machine is defined on 0x20.

    LRESULT ViewBase::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message) {
            case 0x20:
                 AfxMessageBox("User pressed space bar.");
                 break;
        }
}

Thanks




0
Comment
Question by:DJ_AM_Juicebox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 18880244
Yes it is. AFAIK.
0
 
LVL 9

Accepted Solution

by:
Priyesh earned 2000 total points
ID: 18880246
I meant VK_SPACE is consistent.
Although you might want to change your WindowProc to

    LRESULT ViewBase::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message) {
            case WM_KEYDOWN:
                 if(wParam == VK_SPACE)
                    AfxMessageBox("User pressed space bar.");
                 break;
        }
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 18880252
I think you are wanting to make accelerators. Try editing your accelerator in your resources. Add the keys you want commands for there. Then you can add ON_COMMAND handlers for those in your view.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question