#include <afxwin.h>
#include "PrimulMFC.h"

BOOL CPrimaAplicatie::InitInstance()
{
   // m_pMainWnd este membru public al clasei CWinApp, declarat astfel: 
   // CWnd* m_pMainWnd

   m_pMainWnd = new CPrimaFereastra;
   
   // m_nCmdShow este membru public al clasei CWinApp, declarat astfel: 
   // int m_nCmdShow

   m_pMainWnd->ShowWindow(m_nCmdShow);
   m_pMainWnd->UpdateWindow();
   return TRUE;
}

BEGIN_MESSAGE_MAP(CPrimaFereastra, CFrameWnd)
   ON_WM_CLOSE()
   ON_WM_KEYDOWN()
   ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()


CPrimaFereastra::CPrimaFereastra()
{
   // se apeleaza functia membra "Create" a clasei CFrameWnd
   Create(NULL, "Prima mea aplicatie MFC");
}


void CPrimaFereastra::OnClose()
{
   MessageBox("Aplicatie terminata", "Gata", MB_OK|MB_ICONSTOP);
   CFrameWnd::OnClose();
}

void CPrimaFereastra::OnKeyDown(UINT nChar)
{
	CString text;
	switch(nChar){
	   case VK_BACK: text="Ati apasat tasta BackSpace"; break;
  	   case VK_TAB:text="Ati apasat tasta Tab"; break;
 	   case VK_LEFT:text="Ati apasat tasta SageataStinga";break;
	   case VK_RIGHT:text="Ati apasat tasta SageataDreapta"; break;
	   case VK_UP:text="Ati apasat tasta SageataSus"; break;
 	   case VK_DOWN:text="Ati apasat tasta SageataJos"; break;
	   case VK_RETURN:text="Ati apasat tasta Enter"; break;
 	   case VK_ESCAPE:text="Ati apasat tasta Escape"; break;
 	   case VK_CONTROL:text="Ati apasat tasta Control"; break;
	   default: text="Ati apasat alta tasta"; break;
	}
	MessageBox(text, "Mesaj",MB_OK|MB_ICONEXCLAMATION);
}

void CPrimaFereastra::OnRButtonDown(UINT nFlags,CPoint point)
{
	CString text;
	text.Format(" Butonul a fost apasat la coordonatele [ x=%d , y=%d ]",point.x,point.y);
	MessageBox(text);
}

   // obiectul aplicatie
   CPrimaAplicatie primaApp;
