Thread: LPARAM with WM_CHAR

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    LPARAM with WM_CHAR

    Ok, I've been looking at a tutorial for keyboard input... and at the end, it says this:

    Code:
    This following is the BIT values breakdown of the 32-bit LPARAM -- Be sure to check
    	MSDN for any changes
    
    	0 - 15	Specifies the repeat count for the current message. The value is the number of
    			times the keystroke is auto-repeated as a result of the user holding down the key
    
    	16 - 23	Specifies the scan code. The value depends on the original equipment
    			manufacturer (OEM)
    			
    	   24	Specifies whether the key is an extended key, such as the right-hand alt and 
    			ctrl keys that appear on an enhanced 101-key or 102-key keyboard. The value is 1 
    			if it is an extended key otherwise it's 0
    			
    	25 - 28 Reserved
    
    	   29	The context code. The value is 1 if the alt key is held down while 
    			the key is pressed otherwise it's 0
    			
    	   30	The previous key state. The value is 1 if the key is down
    			before the message is sent, or it is 0 if the key is up
    
    	   31	The transition state. The value is 1 if the key is being released, 
    			or it's 0 if the key is being pressed
    The only thing I really need from the LPARAM is the last part, about the key being pressed/released, but how do I get its value? (I mean, do I typecast to a bool or something, or use some macro?)
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    all you need to look at is WPARAM as it contains the key code of the character that was pressed.

    Code:
    if(wParam == 'A')
    {
       // A/a was pressed
    }
    hope this helps
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I got that far, but I want to be able to figure out when the key is released. I actually started out trying to use WM_KEYDOWN/KEYUP, but I couldn't figure out how the virtual-key codes worked. Then I looked at WM_CHAR and it has that flag thingee telling if the message was generated because the key was being pressed or released... I tried doing this:

    Code:
    bool* test = (bool*)&lParam;
    if(test[31] == 0)
           (...)
    It didn't bomb, but when the message was generated, test[31] was always 0.

    Do you know how I might find out what key it is when a WM_KEYDOWN message pops up?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    yeah.. for keys a-z and A-Z they are the same as the actual ascii for uppercase chars.

    so when you can the WM_KEYUP/DOWN messages... test for 'A', 'B', 'C' etc.... all the other keys have a VK_* constant ...that should get you going...

    good luck!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ahhhh, it has to be uppercase eh? That would explain a lot. I kept trying lowercase
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    your welcome!


    manners will get you more help in the future mate.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh, I forgot - thanks! (I thought I usually say thanks anyways?... oh well.)
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    no probs
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Display text in a Dialog Box
    By Dark_Phoenix in forum Windows Programming
    Replies: 9
    Last Post: 01-02-2009, 06:30 AM
  2. classmember WndProc isn't called ...
    By Greenhorn__ in forum Windows Programming
    Replies: 10
    Last Post: 07-19-2008, 11:40 AM
  3. destroywindow() problem
    By algi in forum Windows Programming
    Replies: 6
    Last Post: 03-27-2005, 11:40 PM
  4. button in function
    By algi in forum Windows Programming
    Replies: 1
    Last Post: 03-21-2005, 11:12 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM