博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WTL学习之旅(一) 我的第一个WTL工程
阅读量:2398 次
发布时间:2019-05-10

本文共 2208 字,大约阅读时间需要 7 分钟。

转载请标明是引用于

 相关代码:

安装WTL请参考

WTL环境优化:

修改AppWiz文件夹下setup90x.js 。把第152行 fileDest.WriteLine("Param=\"VC_EXPRESS = 1\""); 这句删除。

 

WTL向导认为如果是Express版本的VC一定是和psdk2003是的atl配合的,具体和atlthunk相关。如果不删除这句,用向导生成程序是运行不了的

然后在AppWiz\Files\Templates\1033文件夹找到stdafx.h 在32行添加#pragma comment(lib,”atlthunk.lib”)。这样用向导生成的程序就不会有链接错误了。

 

工程名为WTLTest。

选择Generate .cpp Files是为了产生cpp文件,这样更符合我们的习惯,不然只有.h文件产生.

调试过程后得知,WTL的调用如下:

1、_tWinMain入口

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_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;} 2、采用ATL初始化模块.

CAppModule _Module;

_Module.Init(

// Overrides of CComModule::Init and Term	HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)	{		HRESULT hRet = CComModule::Init(pObjMap, hInstance, pLibID);		if(FAILED(hRet))			return hRet;		m_dwMainThreadID = ::GetCurrentThreadId();		typedef ATL::CSimpleMap
_mapClass; m_pMsgLoopMap = NULL; ATLTRY(m_pMsgLoopMap = new _mapClass); if(m_pMsgLoopMap == NULL) return E_OUTOFMEMORY; m_pSettingChangeNotify = NULL; return hRet; }

 

结束时是_Module.Term(); 

void Term()	{		TermSettingChangeNotify();		delete m_pMsgLoopMap;		CComModule::Term();	}

3、创建ATL窗口

int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT){	CMessageLoop theLoop;	_Module.AddMessageLoop(&theLoop);	CMainDlg dlgMain;	if(dlgMain.Create(NULL) == NULL)	{		ATLTRACE(_T("Main dialog creation failed!\n"));		return 0;	}	dlgMain.ShowWindow(nCmdShow);	int nRet = theLoop.Run();	_Module.RemoveMessageLoop();	return nRet;}

 

 

 

你可能感兴趣的文章
A-Paper-A-Day--#1-Convolutional-Sequence-to-Sequence-Learning
查看>>
标记问题:介绍
查看>>
利用-TensorFlow-构建卷积神经网络
查看>>
利用TensorFlow实现卷积神经网络做文本分类
查看>>
如何构建高可读性和高可重用的-TensorFlow-模型
查看>>
Ubuntu 安装 pylucene 踩坑还原记,并安装 SmartChineseAnalyzer
查看>>
Java编程思想学习笔记(10)
查看>>
Java编程思想学习笔记(11)
查看>>
机器学习实战:基于Scikit-Learn和TensorFlow—第五章笔记
查看>>
Java编程思想学习笔记(12)
查看>>
Java编程思想学习笔记(14)
查看>>
Java-8-UnaryOperator
查看>>
Java-8-Function
查看>>
Java-8-Stream接口
查看>>
Junit4入门
查看>>
Java与算法(11)
查看>>
Java与算法(13)
查看>>
Python时间模块
查看>>
Python的闭包和装饰器
查看>>
Python基于Socket实现简单聊天室
查看>>