C++ 是在C语言的基础上增加了面向对象程序设计(Object Oriented Programming)支持的语言。
MFC(微软基础类库)
Windows SDK(软件开发工具)
学习要求:
1、养成一种严谨的软件开发习惯,熟悉软件工程的基本原则
2、 C 及C++语言基础,类、继承性、封装性、多态性的概念
3、如何用向导建立一个程序框架
4、设计菜单、工具条、对话框,熟悉最常用的对话框控件
5、知道怎样新建类、成员函数、成员变量、消息处理函数
6、了解最常用的Windows消息
7、了解最简单的GDI(图形设备接口):写文字、画图等
8、熟悉最常用的MFC类
应用程序框架是用于生成一般的应用程序所必须的各种面向对象的软件组件的组合,简单地说就是MFC程序运行的所必须的部分代码集合。应用框架则是MFC程序基于windows系统运行的底层机制,如从WinMain()函数入口,进入窗口消息循环,结束窗口,退出WinMain()主程序。
小例子:
//hello.cpp
#include <afxwin.h>
// Declare the application class
class CHelloApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
// Create an instance of the application class
CHelloApp HelloApp;
// Declare the main window class
class CHelloWindow : public CFrameWnd
{
CStatic* cs;
public:
CHelloWindow();
};
// The InitInstance function is called each
// time the application first executes.
BOOL CHelloApp::InitInstance()
{
m_pMainWnd = new CHelloWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
// The constructor for the window class
CHelloWindow::CHelloWindow()
{
// Create the window itself
Create(NULL,
"Hello World!",
WS_OVERLAPPEDWINDOW,
CRect(0,0,200,200));
// Create a static label
cs = new CStatic();
cs->Create("hello world",
WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(50,80,150,100),
this);
}
运行结果