C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-18-2002, 02:28 PM   #1
Kebab Monster
Guest
 
Posts: n/a
F1 Key input

does any1 know how to get the prog to recognise F1 as an input button to so i can link in a help interface

cheers
  Reply With Quote
Old 03-18-2002, 08:53 PM   #2
Registered User
 
Join Date: Nov 2001
Posts: 162
Yes, it is very simple:
PHP Code:
//Inside the message switch in the main window loop
case WM_KEYDOWN:
    switch(
wParam){
           case 
VK_F1:
                  
//Do whatever
            
break;
     }
break; 
One downside to this simple approach is that it will repeat the process every few milliseconds you hold the F1 key down. To correct that make a bool variable called F1pressed or something and set it to true at the end of the VK_F1 case statement, then code a WM_KEYUP the same as above just make it so it sets the bool variable to FALSE. Then set up an if statement around your help code to check if the bool variable is TRUE or not. I hope you get this!
Crossbow is offline   Reply With Quote
Old 03-19-2002, 03:44 AM   #3
Registered User
 
Join Date: Mar 2002
Posts: 3
What library do i need to include for WM_KEYDOWN, wParam and VK_F1?

cheers

Last edited by Kebab Monster; 03-19-2002 at 04:00 AM.
Kebab Monster is offline   Reply With Quote
Old 03-19-2002, 02:53 PM   #4
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,817
That code is for Windows only.

If you wish to do this in DOS, you will need to write and INT 9 handler. Then you only need to check for the correct scan code for the F1 key (find a scan code table for the keyboard).
Bubba is offline   Reply With Quote
Old 03-20-2002, 04:56 PM   #5
Registered User
 
Join Date: Mar 2002
Posts: 3
Thnx mate
Kebab Monster is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I would love some input on my BST tree. StevenGarcia C++ Programming 4 01-15-2007 01:22 AM
User Input - Key 'Bouncing' = Bad Tonto Windows Programming 1 12-09-2006 09:37 AM
Trouble with a lab michael- C Programming 18 12-06-2005 11:28 PM
Key input? Kavity Linux Programming 0 12-20-2002 11:01 AM
BST/Red and Black Tree ghettoman C++ Programming 0 10-24-2001 10:45 PM


All times are GMT -6. The time now is 11:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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