VC++ 第三课
来源:互联网 发布:淘宝88元xbox360手柄 编辑:程序博客网 时间:2024/06/11 01:35
讲述MFC AppWizard的原理与MFC程序框架的剖析。
AppWizard是一个源代码生成工具,是计算机辅助程序设计工具,WinMain在MFC程序中是如何从源程序中被隐藏的,theApp全局变量是如何被分配的,MFC框架中的几个类的作用与相互关系,MFC框架窗口是如何产生和销毁的,对窗口类的PreCreateWidow和OnCreate两个函数的着重分析,Windows窗口与C++中的CWnd类的关系。
在许多函数中转来转去的,也是似懂非懂的~
#include "iostream"
#include "windows.h"
class CWnd
{
public:
BOOL CreateEx(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, // 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
{//调用内部函数,完成创建
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);//全局函数 win32 api函数
}
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 wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
RegisterClass(&wndcls);
CWnd wnd;//CWnd的成员变量中有句柄,不需再重新定义,也不需传递。。
//wnd不仅仅是一个窗口,窗口销毁时,对象并未销毁,他们之间联系的纽带是变量句柄;但是对象销毁时,窗口必定销毁
//
wnd.CreateEx(...);
wnd.ShowWindow(SW_SHOWNORMAL);
wnd.UpdateWindow();
//显示、更新完窗口后 消息循环
/*
HWND hwnd;
hwnd=CreateWindowEx();
::ShowWindow(hwnd,SW_SHOWNORMAL);
::UpdateWindow(hwnd);
*/
......
}
- VC++ 第三课
- VC视频教程笔记(第三课)
- 孙鑫 VC++ 第三课笔记
- 孙鑫VC第三课学习笔记
- VC++学习第三章
- 孙鑫VC++ 第三课 this指针的问题
- VC++深入详解第三章
- vc小游戏的第三篇
- 《VC++深入详解》第三章
- 孙鑫vc++ 第三课 MFC AppWizard的原理与MFC程序框架的剖析
- 从零开始学习VC++6.0之并口控制(第三课 8位数据端口输出)
- VC++.NET学习笔记(第三章)
- 孙鑫VC学习笔记:第三讲
- VC读写ini文件(第三方开源类)
- 深入浅出VC++串口编程--第三方类
- VC读写ini文件(第三方开源类)
- VC读写ini文件(第三方开源类)
- VC++深入详解第三章学习笔记
- ISO3834国际焊接认证简介
- C64+ cache资料集(更新中)
- 原始套接字
- 下载频道2013上半年超人气精华资源汇总---全都是免积分下载
- Flex中如何通过监听collectionChange事件检测DataGrid的数据源是否改变的例子
- VC++ 第三课
- Android百度地图相关内容汇总
- Address already in use: JVM_Bind<null>:8080
- 开发常用到的函数
- 使用UDL测试SQL Server连接问题
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- 制作jffs2根文件系统
- VC中操作excel表格
- 我安装Opencv时的问题和解决方法