读书时间 2011/11/16 读书时间
2011-11-16 14:19
232 查看
1.《把脉VC++》
Chap 3
* MFC与ATL
ATL中无法使用CWnd
Chap 4
* 赋值与初始化的区别:前者调用operator=(),后者调用constructor
2. 以前关于WTL的笔记
/article/11004121.html
/article/11004122.html
3. WTL例子分析:My2ndWTL70Win
* My2ndWTL70Win.cpp
// HelloWTL70Win2.cpp : main source file for HelloWTL70Win2.exe
//
#include "stdafx.h"
//#include <atlapp.h>
#include <atlframe.h>
#include <atlctrls.h>
#include <atldlgs.h>
#include <atlctrlw.h>
#include "resource.h"
#include "MyMainWnd.h"
//#include "aboutdlg.h"
//#include "maindlg.h"
CAppModule _Module;
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CMyMainWnd MyMainWnd;
if(MyMainWnd.CreateEx() == NULL)
{
ATLTRACE(_T("Main dialog creation failed!\n"));
return 0;
}
MyMainWnd.ShowWindow(nCmdShow);
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
// return 0;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
ATLASSERT(SUCCEEDED(hRes));
// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
::CoUninitialize();
return nRet;
}
总结:
#1. 必须有一个CAppModule的实例,并且名字只能是_Module(因为ATL/WTL类库中直接使用此名字)
CAppModule _Module;
#2.基本steps
各种环境初始化:CoInit, _Module.init
窗口生成与消息循环
环境复位:Com.uninit. _Module.term
#3 窗口生成与消息循环
MessageLoop实便化并加入_Module
主窗口实例化
主窗口生成
主窗口显示
messageLoop.run(消息循环)
_Module删除messaegLoop实例
Chap 3
* MFC与ATL
ATL中无法使用CWnd
Chap 4
* 赋值与初始化的区别:前者调用operator=(),后者调用constructor
2. 以前关于WTL的笔记
/article/11004121.html
/article/11004122.html
3. WTL例子分析:My2ndWTL70Win
* My2ndWTL70Win.cpp
// HelloWTL70Win2.cpp : main source file for HelloWTL70Win2.exe
//
#include "stdafx.h"
//#include <atlapp.h>
#include <atlframe.h>
#include <atlctrls.h>
#include <atldlgs.h>
#include <atlctrlw.h>
#include "resource.h"
#include "MyMainWnd.h"
//#include "aboutdlg.h"
//#include "maindlg.h"
CAppModule _Module;
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CMyMainWnd MyMainWnd;
if(MyMainWnd.CreateEx() == NULL)
{
ATLTRACE(_T("Main dialog creation failed!\n"));
return 0;
}
MyMainWnd.ShowWindow(nCmdShow);
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
// return 0;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
ATLASSERT(SUCCEEDED(hRes));
// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
::CoUninitialize();
return nRet;
}
总结:
#1. 必须有一个CAppModule的实例,并且名字只能是_Module(因为ATL/WTL类库中直接使用此名字)
CAppModule _Module;
#2.基本steps
各种环境初始化:CoInit, _Module.init
窗口生成与消息循环
环境复位:Com.uninit. _Module.term
#3 窗口生成与消息循环
MessageLoop实便化并加入_Module
主窗口实例化
主窗口生成
主窗口显示
messageLoop.run(消息循环)
_Module删除messaegLoop实例
相关文章推荐
- 读书时间 2011/11/20
- 程序员读书时间——《JavaScript框架设计》
- 读书时间2011/06/26 Objective-C
- 读书时间 2011/11/17
- 读书时间 2011/12/24 iPhone/iPad
- 读书时间2011/06/25 - 1 iPhone/iPad相关
- 读书的时间管理的阶段性的总结
- 怎样科学管理读书时间
- 读书:《四点起床-最养生和高效的时间管理》 推荐
- 读书时间《深入浅出Android》 2010-12-15
- 读书时间 2011/10/22
- 读书时间 (1) 正在流行中的书
- 读书时间 2012/01/07
- 读书时间《JavaScript高级程序设计》二:面向对象
- #读书心得#巧用时间读书的小方法
- 读书时间 2011/10/23
- 怎样安排时间读书?
- 读书时间 2012/01/12 iPhone/iPad
- 看其他人是怎么安排读书时间的
- 读书时间 2012/01/04 Linux C/iuPhone/iPad