
目录
- 引出
- 第三讲 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 styleLPCTSTR lpClassName,  // registered class nameLPCTSTR lpWindowName, // window nameDWORD dwStyle,        // window styleint x,                // horizontal position of windowint y,                // vertical position of windowint nWidth,           // window widthint nHeight,          // window heightHWND hWndParent,      // handle to parent or owner windowHMENU hMenu,          // menu handle or child identifierHINSTANCE hInstance,  // handle to application instanceLPVOID lpParam);        // window-creation dataBOOL ShowWindow(int nCmdShow);BOOL UpdateWindow();
public:HWND m_hWnd;
};// 以下是具体的实现
BOOL CWnd::CreateEx(DWORD dwExStyle,DWORD dwExStyle,      // extended window styleLPCTSTR lpClassName,  // registered class nameLPCTSTR lpWindowName, // window nameDWORD dwStyle,        // window styleint x,                // horizontal position of windowint y,                // vertical position of windowint nWidth,           // window widthint nHeight,          // window heightHWND hWndParent,      // handle to parent or owner windowHMENU hMenu,          // menu handle or child identifierHINSTANCE hInstance,  // handle to application instanceLPVOID 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;elsereturn 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 instanceHINSTANCE hPrevInstance,  // handle to previous instanceLPSTR lpCmdLine,          // command lineint 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);...
}
如何加按钮


添加成员变量


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

添加按钮2




更进一步修改


杂项


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