Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyboard picture

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
I want to make a VB app that has a picture of a keyboard, and when you press a key it changes the color of the key on the picture.

What's the best way to do this? Just have a separate picture for each key, and just load in a different picture when it's pressed?
 
There are several ways to do this. Rather than colors, I think I would set up a couple of image lists, with the list index corresponding to the Key Code. ImageList1 would be the Unpressed images, ImageList2 would be the Pressed images.

Then use an array of pictures, buttons, (or some other control that has a picture property) to assemble your keyboard layout. If you make the array index equal to the keycode, this will make it easier to code the transitions.



 
OK i've got an array of buttons. It's mostly working ok, except I'm having trouble capturing the tab, return, space and cursor keys. WHen I press these keys, the KeyDown function doesn't capture the key press- the keys just act on the buttons themselves e.g. tab just switches focus to another button in the array, space presses the button etc.

Any ideas how to get around this?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top