C/C++ Using Arrow Keys as Inputs in C++ for Beginners

  • Thread starter Thread starter 99alastair
  • Start date Start date
AI Thread Summary
The discussion centers around how to use arrow key inputs in a programming context, specifically within Visual Studio while using C++. A user seeks assistance for moving a picture box with arrow key presses. Participants suggest checking ASCII values for arrow keys and clarify that the method of input handling depends on whether the user is working with .NET or MFC. For .NET, setting the KeyPreview property to true allows access to arrow key events in the KeyDown or KeyUp functions. In C++, using Class Wizard or event callbacks with kernel32 is recommended for handling key events. The conversation emphasizes the importance of understanding the programming environment and suggests looking into the samples directory and online resources for further guidance.
99alastair
Messages
3
Reaction score
0
Arrow Key inputs - HELP!

hi. I'm 14 years old and have been programming for a year now. I have now however,come to a point where i need help. I'm using visual studios if that helps. I also program in C++. I have been needing to find out how to use the arrow keys as an input. For instance...When you press the left arrow button, a picture pox moves left etc. Thanks for any help. Alastair
 
Technology news on Phys.org
wow 14? ...search for ASCII values/chart (128 or 256 values)
They should have the arrow key values in them (though it may depend on the type of you keyboard you have).what are you using as your graphics display? .net/mfc?
 
yep, Only 14. I think the graphics is .net but not sure...how do you tell? do you know the code for the arrow key inputs? Thanks. Alastair
 
Last edited:
You don't say what language you are using in visual studio.

If it is VB then this is simple.
Set KeyPreview property of the form to true.
The arrow keystokes will be available in the forms KeyDown or KeyUp function. The only key not available is TAB key.

If C++ then I think this can be done with the Classwizzard.
I never wrote a GUI in C. Just .dlls and UNIX command line code, so I'm not sure.
Worst case here is to set up an event callback with some calls to kernal32.
Try looking in the samples directory.
 
Thanks mate. Normally, i program in C++ but i do know a small bit of VB too.
 
i think anytime you use form its .net and if you use winapp/document/doctemplate/view/framewnd its MFC.

for arrows keys...you can write a simple program to receive character inputs(cin/scanf) and then output the character as hex(%h or x?) or decimal(%d)

it depends on how you are receiving your inputs...and as notime said u can probably access by using classwizard...i'm pretty sure the GUI command is OnKeyChar. or OnKeyPress/Release in MSVC.

search in the environment help...but you may still have to find the ascii or keyboard number.

u can try this
http://www.jguru.com/faq/view.jsp?EID=475275
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Back
Top