GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Feb-2004, 20:15
JBowe JBowe is offline
New Member
 
Join Date: Feb 2004
Posts: 1
JBowe is on a distinguished road

Win32 API Keyboard events


I'm creating an openGL-based pong program and I want to do the keyboard detection with the win32 API.

What are the events for it? I don't have any experience w/ keyboard input on C++ other than cin, sooo any help would be appreciated.
  #2  
Old 29-Feb-2004, 20:53
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi JBowe. Welcome to GIDForums.

Do you have the conio library with your compiler? If so, there should be a function called kbhit() included that may help. It will return a 0 until a key is hit and then it will return that keyhit.

I am not sure if this is what you are looking for or not. It is not strictly a Windows API but is pretty simple if it works for you.
  #3  
Old 01-Mar-2004, 02:27
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by JBowe
I'm creating an openGL-based pong program and I want to do the keyboard detection with the win32 API.

What are the events for it? I don't have any experience w/ keyboard input on C++ other than cin, sooo any help would be appreciated.
Windows API information can be found at
http://msdn.microsoft.com/library/de...y_category.asp
  #4  
Old 01-Mar-2004, 16:43
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
If you are using bare-bones Win32 API, I think you need something like
WM_CHAR.

In your WinMain() function, you probably have a loop with something like
the following:
CPP / C++ / C Code:
 while(GetMessage(&messages, NULL, 0, 0))
    {
           /* Send message to WindowProcedure */
           TranslateMessage(&messages);
           DispatchMessage(&messages);
    }

then in your CALLBACK WindowProcedure(), there is a switch:

CPP / C++ / C Code:
  switch(message) {
//
    case WM_DESTROY:
//
    case WM_CLOSE:
//
//  lots of other cases, probably, and somewhere there is a

     case WM_CHAR:
        // here's where you handle the character.
        // wParam is the integer corresponding to the key that was pressed.

  }
  return 0;





More information probably should come from a windows programming
group.

Dave
  #5  
Old 04-Mar-2004, 12:03
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Seeing no response, I will post my own followup:

Your question is more about Windows programming than about C or C++ programming. This forum has lots of people willing to answer C and/or C++ questions (and to give advice from lots of different points of view). Windows programming is a whole 'nother topic.

For more information about keyboard input in a Windows API application, you can go to http://msdn.microsoft.com, enter keyboard input in the search window, click go and enjoy!


Regards,

Dave
 
 

Recent GIDBlogStupid Management Policies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
list of the most common keyboard and mouse shortcuts for IE, Opera and Firebird jrobbio Computer Software Forum - Windows 2 04-Sep-2003 10:10
A complete Apache + PHP + MySQL Package for Win32 nickbeee MySQL / PHP Forum 1 11-Sep-2001 22:07

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:56.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.