Switching Char Inputs

This is a discussion on Switching Char Inputs within the Windows Programming forums, part of the Platform Specific Boards category; I want to switch the ENTER key with the SPACE key, I've tried the next, but it didn't work. Help ...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Switching Char Inputs

    I want to switch the ENTER key with the SPACE key, I've tried the next, but it didn't work. Help

    Code:
    case WM_CHAR:
                   if (wParam==VK_RETURN) {
                      SendMessage(hwnd, WM_CHAR, VK_SPACE, 0);
                      return(0);
                   }
    Thank you.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Hmm.....well, that should work fine. Two things I can think of that might be causing your problem:

    Have you defined the ES_WANTRETURN style in the creation of the edit control? If not, it's possible that WM_CHAR messages aren't being sent when the return key is pressed.

    Is that all you have for the WM_CHAR case? Remember, you're sending a message to your own window. If you don't handle that message, nothing's going to happen. I don't see a default case that calls the default Edit Control procedure. (I assume you've subclassed the window?)
    Code:
    void function(void)
     {
      function();
     }

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    well actually the program is focused on a button.
    what i am trying to do is allow the user to hit the button using ENTER instead of SPACE
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    please help...
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I think VK_RETURN comes in on the WM_KEYDOWN message... try using case '\n': when handling the WM_CHAR message
    Last edited by The Brain; 07-03-2005 at 12:55 PM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #6
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    no that's not the problem. the problem is with the SPACE send itself.
    Code:
    LRESULT CALLBACK MyButtonProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
     {
        if (Msg==WM_KEYDOWN)
           if (wParam==VK_TAB) {
              SetFocus(GetNextDlgTabItem(GetParent(hwnd), hwnd, 0));
              return(0);
           }
           else if (wParam==VK_SPACE) {
              MessageBox(NULL, "SPACE" , " ", 0);
              return(0);
           }
           else if (wParam==VK_RETURN) { 
              MessageBox(NULL, "RETURN" , " ", 0);
              SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);   // This line doesn't work, the space is not being send
              return(0);
           }
        return CallWindowProc(OriginalButtonProc, hwnd, Msg, wParam, lParam);
    }
    Is there a way to push the button, to make it do whatever it meant to do?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  8. #8
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    well, the BM_CLICK did the trick, but the VK_SPACE didn't work, and the proc couldn't see it?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  3. Conversion Char To Char * Problem
    By ltanusaputra in forum Windows Programming
    Replies: 3
    Last Post: 03-01-2008, 02:06 PM
  4. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 09:54 PM
  5. I'm having a problem with data files.
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 05-14-2003, 10:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21