I am a newbie to windows programming environment in c++,I have to make an on-screen keyboard.
I dont know how to do draw the exact layout of keyboard in Visual C++.
Any help?

Surely your professor has given you more information than you have given us?

Is your application supposed to be text or GUI?
Are you supposed to click on the keys?
If so, what is supposed to happen if you do?
Is this strictly Win32 or are you using some sort of graphics library?
Are you supposed to draw the keyboard yourself, or just to display some keyboard image?

Let us know.

The keyboard is supposed to be GUI.
Its strictly Win32 and preferably no graphics supports mouse movement and whenever buttons are pressed on the real keyboard the on-screen keyboard should reflect the event by changing the corresponding key's color,An on-screen display is also associated with it so that keys pressed can be seen.........

Visual C++ has a pretty good "calculator" example in the free examples that come with Visual C++, including the express version. You press buttons on the calculator and it displays them in the text box portion. It has an action listener for all the buttons. Expand it and you have a keyboard. It doesn't do color changes though, so you would have to tweak that part. I guess you'd have to modify it from listening for buttons pressed with the mouse to a keyboard listener.

If you use that sample program and it is "skipped" when compiling, make sure that, in one of the drop down menus, "Win 32" is selected and not "Itanium", which seems to be the default. It was REAL aggravating till I finally found that exact issue on the MSDN forums.

I am using visual studio 2005 and I dont know how to see the sample codes........
Thanx for the help.

What library are you allowed to use .NET or just MFC ?

Hmm, you've actually got a bit of work ahead of you. I see two possibilites:

Have two pictures of a keyboard: one with all keys up and another with all keys down.
Display the picture of the keyboard with all keys up and whenever you get a keydown or keyup event (WM_KEYDOWN, etc.) copy the appropriate part of the appropriate picture to the image you are displaying to the user.

Using a form designer, drop a tpanel or tbutton or something for each key on the keyboard and arrange them to look like a keyboard. Attach their key up and key down event handlers to something that alters their appearance appropriately.

Good luck.

Here is the calculator sample download address. Not sure whether it requires MFC or what, but here's the site:


Again, if it somehow "skips" during compilation, one possible reason might be this:

Go to "Configuration Manager" in the "Build" pull-down menu.
Within that menu, look at the pulldown menu labeled "Active Solution Platform".

When I first tried to build it, that Active Solution Platform was on "Itanium", so it wouldn't build. When I changed it to "Win 32", everything worked.