วันอังคารที่ 25 มิถุนายน พ.ศ. 2556

การบ้านครั้งที่ 2 สร้างปุ่มกดโทรศัพท์ MFC




================== File.h ==================
#define IDC_MYBUTTON1 1000
#define IDC_MYEDIT 1001

class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};


class CMyFrame : public CFrameWnd
{
public:
CMyFrame();
~CMyFrame();
CButton *myButton;
CEdit*pmyEdit;
};


================== File.cpp ==================
#include <afxwin.h>
#include "labb.h"

CMyApp theApp;

BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);

m_pMainWnd->UpdateWindow();
return TRUE;
 }

 CMyFrame::CMyFrame()
 {
       
Create(NULL,"Hello MOTO",
WS_OVERLAPPEDWINDOW, CRect(10,10,300,375));
pmyEdit = new CEdit;
pmyEdit->Create(ES_AUTOHSCROLL  | WS_VISIBLE | WS_BORDER,
CRect(10,10,240,50),this,IDC_MYEDIT);
myButton = new CButton;
myButton->Create("1",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,80,70,120),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("2",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(95,80,145,120),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("3",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(170,80,220,120),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("4",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,130,70,170),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("5",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(95,130,145,170),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("6",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(170,130,220,170),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("7",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,180,70,220),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("8",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(95,180,145,220),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("9",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(170,180,220,220),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("*",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,230,70,270),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("0",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(95,230,145,270),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("#",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(170,230,220,270),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("Call",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(40,280,115,320),this,IDC_MYBUTTON1);
myButton = new CButton;
myButton->Create("Cancel",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(120,280,190,320),this,IDC_MYBUTTON1);

 }

 CMyFrame::~CMyFrame()
 {
delete myButton;
delete pmyEdit;
 }

ไม่มีความคิดเห็น:

แสดงความคิดเห็น