I use Cakewalk Express version 3 and Cakewalk Home Studio 7, which might be different, but I do know you have to have the devices you are recording from (i.e. the Virtual Piano and/or the MIDI in of your soundcard) selected (highlighted) under the Tools/MIDI devices menu.
You have to have the virtual device driver installed for Virtual Piano to work. I think the option to install it is offered when you install Cakewalk. Also, the driver for the soundcard should have installed itself when you set up the soundcard under Windows.
I had the same problem you are having when I first installed Cakewalk 3 two or three years ago. I never figured out what was wrong, but I finally reinstalled both Cakewalk and the soundcard software and it started working.
Also, when recording, be sure the "Source" cell for the track you are recording is set to "MIDI Omni", and that your external keyboard is set up to transmit on MIDI channel 1. The "Arm" button for the track being recorded doesn't have to be pressed, at least not in version 7, but it might in your version.
Let us know if you get it working.