banner despecable me2

วันศุกร์ที่ 28 มิถุนายน พ.ศ. 2556

lab8 การเขียนโปรแกรม MFC #5

----------------------------------h----------------------------

#include <afxwin.h>

#define IDC_YES_BUTTON 100 // (1) define
#define IDC_NO_BUTTON 101
class CMyApp : public CWinApp // create application
{
public:
virtual BOOL  InitInstance();
};

class CMyFrame : public CFrameWnd //create window
{
public:
CMyFrame();
~CMyFrame();
CButton *myButton1;
CButton *myButton2;// (2) declare button control

afx_msg void YesClicked();
afx_msg void NoClicked();

DECLARE_MESSAGE_MAP();
};

___________________cpp__________________


#include "S1.h"


CMyApp theApp; // create application object

BEGIN_MESSAGE_MAP(CMyFrame , CFrameWnd)
ON_BN_CLICKED(IDC_YES_BUTTON,YesClicked)
ON_BN_CLICKED(IDC_NO_BUTTON,NoClicked)
END_MESSAGE_MAP()
void CMyFrame :: YesClicked()
MessageBox("YES");
}
void CMyFrame :: NoClicked()
MessageBox("No");
}


BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame(); // create windows frame object and link to application
m_pMainWnd->ShowWindow(m_nCmdShow); //show frame windows

m_pMainWnd->UpdateWindow(); // update frame windows
return TRUE;
}

CMyFrame::CMyFrame()
{
myButton1 = new CButton();
myButton2 = new CButton();
// (3) memory allocation
Create(NULL,"Hello Visual c++, Easy MFC 01", 
WS_OVERLAPPEDWINDOW, CRect(100,100,500,300));
// (4) create control

myButton1 -> Create("YES", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(10,10,100,50),this,IDC_YES_BUTTON);
myButton2 -> Create("NO", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(110,10,210,50),this,IDC_NO_BUTTON);
}

CMyFrame::~CMyFrame()
{
delete myButton1;
delete myButton2;
}

lab7 การเขียนโปรแกรม MFC #4

---------------h--------------
#include <afxwin.h>

#define IDC_MYBUTTON1 1001 // (1) define

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

class CMyFrame : public CFrameWnd //create window
{
public:
CMyFrame();
~CMyFrame();
CButton *myButton1;

afx_msg void OnClick1();

DECLARE_MESSAGE_MAP();
};

-----------------------cpp-------------

#include "S1.h"


CMyApp theApp; // create application object

BEGIN_MESSAGE_MAP(CMyFrame , CFrameWnd)
ON_BN_CLICKED(IDC_MYBUTTON1,OnClick1)
END_MESSAGE_MAP()
void CMyFrame :: OnClick1()
MessageBox("Hello, I LOVE YOU");
}



BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame(); // create windows frame object and link to application
m_pMainWnd->ShowWindow(m_nCmdShow); //show frame windows

m_pMainWnd->UpdateWindow(); // update frame windows
return TRUE;
}

CMyFrame::CMyFrame()
{
myButton1 = new CButton();
// (3) memory allocation
Create(NULL,"Hello Visual c++, Easy MFC 01", 
WS_OVERLAPPEDWINDOW, CRect(100,100,500,300));
// (4) create control
myButton1 -> Create("Click me", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(10,10,100,50),this,IDC_MYBUTTON1);
}

CMyFrame::~CMyFrame()
{
delete myButton1;

}



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

BASIC Mobile HomeWork2

>>>MOBILE.h<<<

#include <afxwin.h>

#define IDC_MYEDIT 1001     
#define IDC_MYBUTTON 2002    

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

class CMyFrame : public CFrameWnd        
{
 public:
 CMyFrame();
 ~CMyFrame();
 CEdit *pmyEdit;      
 CButton *pmyButton[12];
};
---------------------------------------------------

>>>MOBILE.cpp<<<


#include "MOBILE.h"
CMyApp theApp;
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
char* y1[] = {"1","4","6","*"};
char* y2[] = {"2","5","7","0"};
char* y3[] = {"3","6","9","#"};
CMyFrame::CMyFrame()
{
Create(NULL,"BASIC Mobile",WS_OVERLAPPEDWINDOW, CRect(100,100,370,500));

// create control
pmyEdit = new CEdit;
pmyEdit->Create(WS_VISIBLE | WS_CHILD| WS_BORDER ,CRect(10,10,240,80),this,IDC_MYBUTTON);

for(int i = 0; i<4 ; i++)
{
pmyButton[i] = new CButton();
pmyButton[i]->Create(y1[i],WS_VISIBLE | WS_BORDER ,CRect(10,(i*60)+120,80,(i*60)+160),this,IDC_MYBUTTON +i );
}


for(int i = 0; i<4 ; i++)
{
pmyButton[i] = new CButton();
pmyButton[i]->Create(y2[i],WS_VISIBLE | WS_BORDER ,CRect(90,(i*60)+120,160,(i*60)+160),this,IDC_MYBUTTON +i );
}

for(int i = 0; i<4 ; i++)
{
pmyButton[i] = new CButton();
pmyButton[i]->Create(y3[i], WS_VISIBLE | WS_BORDER ,CRect(170,(i*60)+120,240,(i*60)+160),this,IDC_MYBUTTON +i );
}
pmyButton[a] = new CButton();
pmyButton[a]->Create("Call", WS_VISIBLE | WS_BORDER ,CRect(10,90,100,110),this,IDC_MYBUTTON );
pmyButton[b] = new CButton();
pmyButton[b]->Create("End", WS_VISIBLE | WS_BORDER ,CRect(150,90,240,110),this,IDC_MYBUTTON );

}
CMyFrame::~CMyFrame()
{
delete pmyButton[i];
delete pmyButton[b];
delete pmyButton[a];
}