Solved

VK_SPACE

Posted on 2007-04-09
3
1,923 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
  • 3
3 Comments
 
LVL 9

Expert Comment

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

Accepted Solution

by:
Priyesh earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 58
either24  challenge 19 84
Post a good COM tutorial 1 34
Dialogbox API leak? 18 60
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now