step 1: Open VC++ 6.0
Step 2: File --> New --> Projects --> Win32 Application
Give your project name
Step 3: File --> New --> Files --> C++ Source File
Give your file name
step 4: In your CPP file
/* Mfc program to handle virtual key codes. */
#include<afxwin.h>
class myframe : public CFrameWnd
{
public:
myframe()
{
Create(0,"Menu Program");
}
void OnKeyDown(UINT n)
{
switch(n)
{
case VK_LEFT:
MessageBox("Left Arrow","Hellow");
break;
case VK_RIGHT:
MessageBox("Right Arrow","Hellow");
break;
case VK_UP:
MessageBox("Up Arrow","Hellow");
break;
case VK_DOWN:
MessageBox("Down Arrow","Hellow");
break;
case VK_NUMPAD0:
MessageBox("Number ZERO","Hellow");
break;
case VK_NUMPAD9:
MessageBox("Number NINE","Hellow");
break;
case VK_SPACE:
MessageBox("Space Bar","Hellow");
break;
case VK_BACK:
MessageBox("BACK KEY","Hellow");
break;
case VK_SHIFT:
MessageBox("SHIFT KEY","Hellow");
break;
}
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
class myapp : public CWinApp
{
public:
int InitInstance()
{
m_pMainWnd=new myframe();
m_pMainWnd->ShowWindow(3);
return 1;
}
};
myapp app;
step 5: Project --> settings --> Choose MFC as shared DLL
Step 6: Bulid --> Compile
step 7: Build --> Build
Step 8: Build --> Execute