读书时间 2011/11/16 读书时间

15 篇文章 0 订阅
5 篇文章 0 订阅

 

1.《把脉VC++》

 

Chap 3

* MFC与ATL

ATL中无法使用CWnd

 

Chap 4

* 赋值与初始化的区别:前者调用operator=(),后者调用constructor

 

2. 以前关于WTL的笔记

http://blog.csdn.net/printf1998/article/details/6401743

http://blog.csdn.net/printf1998/article/details/6403104

 

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实例

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值