Tuesday, 14 February 2017

BASIC EVENT HANDLING

Ex:

#include<afxwin.h>
classMyFrame:publicCFrameWnd
{
public:MyFrame()
             {
                   Create(NULL,"Simple Window");
             }
          voidOnLButtonDown(UINT flag,CPointpt)//Mouse Event Handler
             {
                   MessageBox("Left Button Pressed");
             }
          voidOnKeyUp(UINT ascii,UINTnrpt,UINT scan)//Key Board Message Handler
             {
                   MessageBox("Key is pressed");
             }
             DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_KEYUP()
END_MESSAGE_MAP()
classMyMain:publicCWinApp
{
public:intInitInstance()
             {
                   MyFrame *f=new MyFrame();
                   f->ShowWindow(1);
                   m_pMainWnd=f;
                   return 1;
             }
};

MyMain m;

No comments:
Write comments