MFC工程能否/如何使用ATL::CString,不是MFC的CString!

gpmn 2004-07-03 05:03:30
如题
...全文
193 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
MissYouChenMin 2004-07-04
  • 打赏
  • 举报
回复
如何使用看MSDN
MissYouChenMin 2004-07-04
  • 打赏
  • 举报
回复
绝对可以使用
豆腐 2004-07-04
  • 打赏
  • 举报
回复
可以使用!
------------------------------------
体验速度,体验CSDN新版论坛助手:http://community.csdn.net/Expert/TopicView.asp?id=3108679
lixiaosan 2004-07-03
  • 打赏
  • 举报
回复
在msdn2003里你会找到很多相关的内容。。他们的操作都差不多。。
蒋晟 2004-07-03
  • 打赏
  • 举报
回复
MSDN里面不是有帮助么?从MFC的CString发展出来的,用法也差不多
// ============================================================================= // FILE: StdString.h // AUTHOR: Joe O'Leary (with outside help noted in comments) // // If you find any bugs in this code, please let me know: // // jmoleary@earthlink.net // http://www.joeo.net/stdstring.htm (a bit outdated) // // The latest version of this code should always be available at the // following link: // // http://www.joeo.net/code/StdString.zip (Dec 6, 2003) // // // REMARKS: // This header file declares the CStdStr template. This template derives // the Standard C++ Library basic_string<> template and add to it the // the following conveniences: // - The full MFC CString set of functions (including implicit cast) // - writing to/reading from COM IStream interfaces // - Functional objects for use in STL algorithms // // From this template, we intstantiate two classes: CStdStringA and // CStdStringW. The name "CStdString" is just a #define of one of these, // based upone the UNICODE macro setting // // This header also declares our own version of the MFC/ATL UNICODE-MBCS // conversion macros. Our version looks exactly like the Microsoft's to // facilitate portability. // // NOTE: // If you you use this in an MFC or ATL build, you should include either // afx.h or atlbase.h first, as appropriate. // // PEOPLE WHO HAVE CONTRIBUTED TO THIS CLASS: // // Several people have helped me iron out problems and othewise improve // this class. OK, this is a long list but in my own defense, this code // has undergone two major rewrites. Many of the improvements became // necessary after I rewrote the code as a template. Others helped me // improve the CString facade. // // Anyway, these people are (in chronological order): // // - Pete the Plumber (???) // - Julian Selman // - Chris (of Melbsys) // - Dave Plummer // - John C Sipos // - Chris Sells // - Nigel Nunn // - Fan Xia // - Matthew Williams // - Carl Engman // - Mark Zeren // - Craig Watson // - Rich Zuris // - Karim Ratib // - Chris Conti // - Baptiste Lepilleur // - Greg Pickles // - Jim Cline // - Jeff Kohn // - Todd Heckel // - Ullrich Poll?hne // - Joe Vitaterna // - Joe Woodbury // - Aaron (no last name) // - Joldakowski (???) // - Scott Hathaway // - Eric Nitzche // - Pablo Presedo // - Farrokh Nejadlotfi // - Jason Mills // - Igor Kholodov // - Mike Crusader // - John James // - Wang Haifeng // - Tim Dowty // - Arnt Witteveen // - Glen Maynard // - Paul DeMarco // - Bagira (full name?) // - Ronny Schulz // - Jakko Van Hunen // - Charles Godwin // - Henk Demper // - Greg Marr // - Bill Carducci // - Brian Groose // - MKingman // - Don Beusee // // REVISION HISTORY // // 2005-JAN-10 - Thanks to Don Beusee for pointing out the danger in mapping // length-checked formatting functions to non-length-checked // CRT equivalents. Also thanks to him for motivating me to // optimize my implementation of Replace() // // 2004-APR-22 - A big, big thank you to "MKingman" (whoever you are) for // finally spotting a silly little error in StdCodeCvt that // has been causing me (and users of CStdString) problems for // years in some relatively rare conversions. I had reversed // two length arguments. // // 2003-NOV-24 - Thanks to a bunch of people for helping me clean up many // compiler warnings (and yes, even a couple of actual compiler // errors). These include Henk Demper for figuring out how // to make the Intellisense work on with CStdString on VC6, // something I was never able to do. Greg Marr pointed out // a compiler warning about an unreferenced symbol and a // problem with my version of Load in MFC builds. Bill // Carducci took a lot of time with me to help me figure out // why some implementations of the Standard C++ Library were // returning error codes for apparently successful conversions // between ASCII and UNICODE. Finally thanks to Brian Groose // for helping me fix compiler signed unsigned warnings in // several functions. // // 2003-JUL-10 - Thanks to Charles Godwin for making me realize my 'FmtArg' // fixes had inadvertently broken the DLL-export code (which is // normally commented out. I had to move it up higher. Also // this helped me catch a bug in ssicoll that would prevent // compilation, otherwise. // // 2003-MAR-14 - Thanks to Jakko Van Hunen for pointing out a copy-and-paste // bug in one of the overloads of FmtArg. // // 2003-MAR-10 - Thanks to Ronny Schulz for (twice!) sending me some changes // to help CStdString build on SGI and for pointing out an // error in placement of my preprocessor macros for ssfmtmsg. // // 2002-NOV-26 - Thanks to Bagira for pointing out that my implementation of // SpanExcluding was not properly handling the case in which // the string did NOT contain any of the given characters // // 2002-OCT-21 - Many thanks to Paul DeMarco who was invaluable in helping me // get this code working with Borland's free compiler as well // as the Dev-C++ compiler (available free at SourceForge). // // 2002-SEP-13 - Thanks to Glen Maynard who helped me get rid of some loud // but harmless warnings that were showing up on g++. Glen // also pointed out that some pre-declarations of FmtArg<> // specializations were unnecessary (and no good on G++) // // 2002-JUN-26 - Thanks to Arnt Witteveen for pointing out that I was using // static_cast<> in a place in which I should have been using // reinterpret_cast<> (the ctor for unsigned char strings). // That's what happens when I don't unit-test properly! // Arnt also noticed that CString was silently correcting the // 'nCount' argument to Left() and Right() where CStdString was // not (and crashing if it was bad). That is also now fixed! // // 2002-FEB-25 - Thanks to Tim Dowty for pointing out (and giving me the fix // for) a conversion problem with non-ASCII MBCS characters. // CStdString is now used in my favorite commercial MP3 player! // // 2001-DEC-06 - Thanks to Wang Haifeng for spotting a problem in one of the // assignment operators (for _bstr_t) that would cause compiler // errors when refcounting protection was turned off. // // 2001-NOV-27 - Remove calls to operator!= which involve reverse_iterators // due to a conflict with the rel_ops operator!=. Thanks to // John James for pointing this out. // // 2001-OCT-29 - Added a minor range checking fix for the Mid function to // make it as forgiving as CString's version is. Thanks to // Igor Kholodov for noticing this. // - Added a specialization of std::swap for CStdString. Thanks // to Mike Crusader for suggesting this! It's commented out // because you're not supposed to inject your own code into the // 'std' namespace. But if you don't care about that, it's // there if you want it // - Thanks to Jason Mills for catching a case where CString was // more forgiving in the Delete() function than I was. // // 2001-JUN-06 - I was violating the Standard name lookup rules stated // in [14.6.2(3)]. None of the compilers I've tried so // far apparently caught this but HP-UX aCC 3.30 did. The // fix was to add 'this->' prefixes in many places. // Thanks to Farrokh Nejadlotfi for this! // // 2001-APR-27 - StreamLoad was calculating the number of BYTES in one // case, not characters. Thanks to Pablo Presedo for this. // // 2001-FEB-23 - Replace() had a bug which caused infinite loops if the // source string was empty. Fixed thanks to Eric Nitzsche. // // 2001-FEB-23 - Scott Hathaway was a huge help in providing me with the // ability to build CStdString on Sun Unix systems. He // sent me detailed build reports about what works and what // does not. If CStdString compiles on your Unix box, you // can thank Scott for it. // // 2000-DEC-29 - Joldakowski noticed one overload of Insert failed to do a // range check as CString's does. Now fixed -- thanks! // // 2000-NOV-07 - Aaron pointed out that I was calling static member // functions of char_traits via a temporary. This was not // technically wrong, but it was unnecessary and caused // problems for poor old buggy VC5. Thanks Aaron! // // 2000-JUL-11 - Joe Woodbury noted that the CString::Find docs don't match // what the CString::Find code really ends up doing. I was // trying to match the docs. Now I match the CString code // - Joe also caught me truncating strings for GetBuffer() calls // when the supplied length was less than the current length. // // 2000-MAY-25 - Better support for STLPORT's Standard library distribution // - Got rid of the NSP macro - it interfered with Koenig lookup // - Thanks to Joe Woodbury for catching a TrimLeft() bug that // I introduced in January. Empty strings were not getting // trimmed // // 2000-APR-17 - Thanks to Joe Vitaterna for pointing out that ReverseFind // is supposed to be a const function. // // 2000-MAR-07 - Thanks to Ullrich Poll?hne for catching a range bug in one // of the overloads of assign. // // 2000-FEB-01 - You can now use CStdString on the Mac with CodeWarrior! // Thanks to Todd Heckel for helping out with this. // // 2000-JAN-23 - Thanks to Jim Cline for pointing out how I could make the // Trim() function more efficient. // - Thanks to Jeff Kohn for prompting me to find and fix a typo // in one of the addition operators that takes _bstr_t. // - Got rid of the .CPP file - you only need StdString.h now! // // 1999-DEC-22 - Thanks to Greg Pickles for helping me identify a problem // with my implementation of CStdString::FormatV in which // resulting string might not be properly NULL terminated. // // 1999-DEC-06 - Chris Conti pointed yet another basic_string<> assignment // bug that MS has not fixed. CStdString did nothing to fix // it either but it does now! The bug was: create a string // longer than 31 characters, get a pointer to it (via c_str()) // and then assign that pointer to the original string object. // The resulting string would be empty. Not with CStdString! // // 1999-OCT-06 - BufferSet was erasing the string even when it was merely // supposed to shrink it. Fixed. Thanks to Chris Conti. // - Some of the Q172398 fixes were not checking for assignment- // to-self. Fixed. Thanks to Baptiste Lepilleur. // // 1999-AUG-20 - Improved Load() function to be more efficient by using // SizeOfResource(). Thanks to Rich Zuris for this. // - Corrected resource ID constructor, again thanks to Rich. // - Fixed a bug that occurred with UNICODE characters above // the first 255 ANSI ones. Thanks to Craig Watson. // - Added missing overloads of TrimLeft() and TrimRight(). // Thanks to Karim Ratib for pointing them out // // 1999-JUL-21 - Made all calls to GetBuf() with no args check length first. // // 1999-JUL-10 - Improved MFC/ATL independence of conversion macros // - Added SS_NO_REFCOUNT macro to allow you to disable any // reference-counting your basic_string<> impl. may do. // - Improved ReleaseBuffer() to be as forgiving as CString. // Thanks for Fan Xia for helping me find this and to // Matthew Williams for pointing it out directly. // // 1999-JUL-06 - Thanks to Nigel Nunn for catching a very sneaky bug in // ToLower/ToUpper. They should call GetBuf() instead of // data() in order to ensure the changed string buffer is not // reference-counted (in those implementations that refcount). // // 1999-JUL-01 - Added a true CString facade. Now you can use CStdString as // a drop-in replacement for CString. If you find this useful, // you can thank Chris Sells for finally convincing me to give // in and implement it. // - Changed operators << and >> (for MFC CArchive) to serialize // EXACTLY as CString's do. So now you can send a CString out // to a CArchive and later read it in as a CStdString. I have // no idea why you would want to do this but you can. // // 1999-JUN-21 - Changed the CStdString class into the CStdStr template. // - Fixed FormatV() to correctly decrement the loop counter. // This was harmless bug but a bug nevertheless. Thanks to // Chris (of Melbsys) for pointing it out // - Changed Format() to try a normal stack-based array before // using to _alloca(). // - Updated the text conversion macros to properly use code // pages and to fit in better in MFC/ATL builds. In other // words, I copied Microsoft's conversion stuff again. // - Added equivalents of CString::GetBuffer, GetBufferSetLength // - new sscpy() replacement of CStdString::CopyString() // - a Trim() function that combines TrimRight() and TrimLeft(). // // 1999-MAR-13 - Corrected the "NotSpace" functional object to use _istpace() // instead of _isspace() Thanks to Dave Plummer for this. // // 1999-FEB-26 - Removed errant line (left over from testing) that #defined // _MFC_VER. Thanks to John C Sipos for noticing this. // // 1999-FEB-03 - Fixed a bug in a rarely-used overload of operator+() that // caused infinite recursion and stack overflow // - Added member functions to simplify the process of // persisting CStdStrings to/from DCOM IStream interfaces // - Added functional objects (e.g. StdStringLessNoCase) that // allow CStdStrings to be used as keys STL map objects with // case-insensitive comparison // - Added array indexing operators (i.e. operator[]). I // originally assumed that these were unnecessary and would be // inherited from basic_string. However, without them, Visual // C++ complains about ambiguous overloads when you try to use // them. Thanks to Julian Selman to pointing this out. // // 1998-FEB-?? - Added overloads of assign() function to completely account // for Q172398 bug. Thanks to "Pete the Plumber" for this // // 1998-FEB-?? - Initial submission // // COPYRIGHT: // 2002 Joseph M. O'Leary. This code is 100% free. Use it anywhere you // want. Rewrite it, restructure it, whatever. If you can write software // that makes money off of it, good for you. I kinda like capitalism. // Please don't blame me if it causes your $30 billion dollar satellite // explode in orbit. If you redistribute it in any form, I'd appreciate it // if you would leave this notice here. // ============
中文名: 深入解析ATL(第2版) 原名: ATL Internals, 2nd Edition Working with ATL 8 别名: ATL 作者: (美)塔瓦瑞斯译者: 赖仪灵 曹雨田 资源格式: PDF 版本: 扫描版 出版社: 电子工业出版社书号: 9787121049859发行时间: 2007年11月01日 地区: 大陆 语言: 简体中文 简介: 编辑推荐 ATL的发明人Jim Springfield亲自作序推荐。   四位顶尖的Windows编程专家倾力合作,绝对经典再现。   COM、ATL开发人员的必备宝典。   深入分析ATL实现COM内幕细节,展示COM应用中的各类漂亮技巧。   ATL的经典指南现已更新到ATL 8和VisuaI Studio 2005:   四位顶尖的Windows编程专家在本书中系统地揭示了ATL的内部工作原理,他们解释了ATL是 如何工作的,以及为什么要以这样的方式工作。通过本书,客户端开发人员可以掌握ATL中的窗口、COM控件、MFC集成、Web服务代理生成等资源。服务端编程人员可以应用ATL的全COM服务器和对象服务、高吞吐量、高并发Web应用程序和服务的广泛支持。每个Windows开发人员都将从本书中学到强大的方法来增加应用程序的灵活性、减少负载、最大化程序的透明度和可控性。   ·通过图表、示例代码和ATL的内部实现代码来揭密ATL的内部原理。   ·遍历向导以简化在普通应用程序中的ATL开发。   ·掌握C++、COM和ATL中的字符串使用技巧。   ·利用ATL的智能类型:CComPtr、CComQIPtr、CComBSTR和CComVariant。   ·理解并正确实现IUnknown。   ·创建能从COM服务器中暴露COM对象的粘合代码。   ·使用Canned Interface实现来支持对象的永久性、COM集合、枚举器和连接点。   ·使用ATL窗口类和控件建立独立的应用程序和UI组件。   ·使用ATL Servet开发可以运行在微软IIS上的Web应用程序。 虽然.NET系统从1998年才开始其发展进程。但它已经使很多开发人员的编程发生了革命性的变化,并在未来几年将持续得到改进。但是,COM编程(和 ATL)也依然非常有活力,对Microsoft内外的很多开发人员都非常重要。本书的第2版,与第1版一样,提供了您所需要的信息,使我们在这些技术上的投资也将获得最大的回报。                        ——Jim Springfield,ATL发明人 虽然ATL比较精深,但是这本书的讲解非常通俗易懂,语言比较简练,条理非常清楚。即使在读完这本书之后,它仍然可以作为参考书指导我们的开发和学习工作。我想,这就是好书的价值所在吧。            ——潘爱民,经典畅销书《深入解析Windows操作系统,第4版》译者 内容简介 本书主要介绍了ATL技术的原理、内部实现和应用技巧,由当今4 位顶尖的 Windows技术专家联合撰写。全书内容丰富,深入浅出,主要涵盖了ATL内部架构和实现方法、运用向导简化ATL开发、C++/COM/ATL中字符串的使用技巧、理解并正确实现IUnknown、充分利用ATL提供的Smart Types、撰写能够暴露COM服务器上COM对象的粘合代码、利用Canned Interface实现来支持对象持久化/COM群集/枚举、利用ATL Windows类建构独立的应用程序和UI组件等的技术内容。本书适合于广大Windows开发人员阅读参考,是ATL开发人员的必备权威参考书籍。 作者简介 Christopher Tavares,目前在微软工作,是模式与实践方面的专家。有着超过25年的编程经验,涉及的平台从Sinclair ZX-81到多CPU信号处理硬件。 目录: 第2版序 第1版序 前言 致谢 关于作者 联系博文视点 第1章 你好,ATL 1.1 什么是ATL 1.2 创建COM服务器 1.3 插入COM类 1.4 添加属性和方法 1.5 实现附加接口 1.6 脚本支持 1.7 添加永久性 1.8 添加和激发事件 1.9 使用窗口 1.10 COM控件 1.11 容纳控件 1.12 ATL Server Web项目 1.13 总结 第2章 字符串和文本 2.1 字符串数据类型、转换类和辅助函数 2.2 智能BSTR类CComBSTR 2.3 CComBSTR类 2.4 CString类 2.5 总结 第3章 ATL智能类型 3.1 智能VARIANT类CComVariant 3.2 智能SAFEARRAY类CComSafeArray 3.3 智能指针类CComPtr和CComQIPtr 3.4 智能指针类CAutoPtr和CAutoVectorPtr 3.5 ATL内存管理器 3.6 总结 第4章 ATL中的对象 4.1 实现IUnknown 4.2 ATL的层次 4.3 线程模型支持 4.4 IUnknow核心 4.5 我们的类 4.6 CComObject以及其他 4.7 ATL创建者 4.8 调试 4.9 总结 第5章 COM服务器 5.1 回顾COM服务器 5.2 对象映射表和CAtlModule类 5.3 对象映射表 5.4 对象映射类要求的方法 5.5 CAtlModule类 5.6 重游CComCoClass 5.7 ATL与C运行时库 5.8 总结 第6章 接口映射表 6.1 回顾:COM的实体身份 6.2 表驱动的QueryInterface 6.3 多重继承 6.4 Tear-off接口 6.5 聚合:外部控制对象 6.6 接口映射表链 6.7 尽管说“不” 6.8 调试 6.9 扩展性 6.10 总结 第7章 ATL中的永久性 7.1 回顾COM的永久性 7.2 ATL的永久性实现类 7.3 属性映射表 7.4 永久性实现 7.5 其他永久性实现 7.6 使用永久性添加“按值列集”的语义 7.7 总结 第8章 集合和枚举器 8.1 COM集合和枚举接口 8.2 枚举数组 8.3 枚举标准的C++集合 8.4 集合 8.5 ATL数据类型的标准C++集合 8.6 ATL集合 8.7 对象模型 8.8 总结 第9章 连接点 9.1 回顾连接点 9.2 创建基于ATL的可连接对象 9.3 创建一个接收事件的对象 9.4 它是怎么工作的:杂乱的实现细节 9.5 总结 第10章 窗口 10.1 Windows应用程序的结构 10.2 CWindow 10.3 CWindowImpl 10.4 CDialogImpl 10.5 Windows控件包装类 10.6 CContainedWindow 10.7 总结 第11章 ActiveX控件 11.1 回顾ActiveX控件 11.2 BullsEye控件需求 11.3 使用ATL向导创建初始的控件 11.4 初始的BullsEye源文件 11.5 逐步开发BullsEye控件 11.6 总结 第12章 控件包容 12.1 控件是如何被包容的 12.2 基本的控件包容 12.3 在对话框中容纳控件 12.4 复合控件 12.5 HTML控件 12.6 ATL控件包容的限制 12.7 总结 第13章 你好,ATL Server:一个新型的C++ Web平台 13.1 微软Web平台(因特网信息服务) 13.2 可能是可以运行的最简单ISAPI扩展 13.3 封装ISAPI 13.4 ATL Server 13.5 ATL Server中的Web服务 13.6 总结 第14章 ATL Server内幕 14.1 ATL Server中的ISAPI实现 14.2 服务器响应文件 14.3 请求处理程序示例 14.4 输入处理 14.5 会话管理 14.6 数据缓存 14.7 总结 附录A 实例展示C++模板 A.1 模板的必要性 A.2 模板基础 A.3 不同类型的多态 A.4 函数模板 A.5 成员函数模板 A.6 总结 附录B ATL头文件 附录C 移植到ATL 8 C.1 字符串、字符集和转换 C.2 与MFC共享的类 C.3 实现COM服务器 C.4 ActiveX控件和控件容纳 C.5 ATL_MIN_CRT变化 C.6 总结 附录D 属性化ATL D.1 ATL Attributes的基础 D.2 属性化ATL的未来 D.3 总结 索引

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧