Solved

VK_SPACE

Posted on 2007-04-09
3
1,931 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

730 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