
目录
- 引出
 - 第三讲 MFC框架
 - 新建项目
 - Windows搜索【包含内容的搜索】
 - 如何加按钮
 - 添加成员变量
 - 添加成功
 
- 添加按钮2
 - 杂项
 
- 总结
 
引出
VC++学习(3)——认识MFC框架,新建项目,添加按钮
MFC(Microsoft Foundation Classes),是微软公司提供的一个类库(class libraries),以C++类的形式封装了Windows的API,并且包含一个应用程序框架,以减少应用程序开发人员的工作量。其中包含的类包含大量Windows句柄封装类和很多Windows的内建控件和组件的封装类。
第三讲 MFC框架
新建项目




在帮助文档中查看类的继承关系

Windows搜索【包含内容的搜索】



class CWnd
{
public:
	BOOL CreateEx(
			DWORD dwExStyle,
			DWORD dwExStyle,      // extended window style
			LPCTSTR lpClassName,  // registered class name
			LPCTSTR lpWindowName, // window name
			DWORD dwStyle,        // window style
			int x,                // horizontal position of window
			int y,                // vertical position of window
			int nWidth,           // window width
			int nHeight,          // window height
			HWND hWndParent,      // handle to parent or owner window
			HMENU hMenu,          // menu handle or child identifier
			HINSTANCE hInstance,  // handle to application instance
			LPVOID lpParam);        // window-creation data
	BOOL ShowWindow(int nCmdShow);
	BOOL UpdateWindow();
public:
	HWND m_hWnd;
};
// 以下是具体的实现
BOOL CWnd::CreateEx(
			DWORD dwExStyle,
			DWORD dwExStyle,      // extended window style
			LPCTSTR lpClassName,  // registered class name
			LPCTSTR lpWindowName, // window name
			DWORD dwStyle,        // window style
			int x,                // horizontal position of window
			int y,                // vertical position of window
			int nWidth,           // window width
			int nHeight,          // window height
			HWND hWndParent,      // handle to parent or owner window
			HMENU hMenu,          // menu handle or child identifier
			HINSTANCE hInstance,  // handle to application instance
			LPVOID lpParam)        // window-creation data
{
	// ::表示调用的是平台全局API函数,
	m_hWnd =::CreateWindowEx(dwExStyle,lpClassName,dwStyle,x,y,nWidth,nHeight,hWndParent,
							hMenu,hInstance,lpParam);
	if(m_hWnd!=NULL)
		return TRUE;
	else
		return FALSE;
}
BOOL CWnd::ShowWindow(int nCmdShow)
{
	return ::ShowWindow(m_hWnd,nCmdShow);
}
BOOL CWnd::UpdateWindow()
{
	return ::UpdateWindow(m_hWnd);
}
// 主程序
int WINAPI WinMain(  
  HINSTANCE hInstance,      // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,          // command line
  int nCmdShow)              // show state);
{
	WNDCLASS cls;
	cls.cbClsExtra = 0;
	cls.cbWndExtra = 0;
	.....
	RegisterClass(&cls);
	CWnd wnd;
	wnd.CreateEx(...);
	wnd.ShowWindow(SW_SHOWNORMAL);
	wnd.UpdateWindow();
	HWND hwnd;
	hwnd=CreateWindowEx();
	::ShowWindow(hwnd,SW_SHOWNORMAL);
	::UpdateWindow(hwnd);
	...
}
 
如何加按钮


添加成员变量


添加成功
	// 定义一个cbutton
	m_btn.Create("weixin",WS_CHILD | BS_DEFPUSHBUTTON, CRect(0,0,100,100),this,123);
	// 显示
	m_btn.ShowWindow(SW_SHOWNORMAL);
 

添加按钮2




更进一步修改


杂项


总结
VC++学习(3)——认识MFC框架,新建项目,添加按钮








![【Linux】-Elasticsearch安装部署[16]](https://img-blog.csdnimg.cn/direct/c133b9e39074499e8594dc36ec193009.png)










