WTL 8.0 初探(一)

    技术2022-05-11  92

    WTL(Windows Template Library),我自己叫他“窗口模板库”,它其实是ATL的一个扩展,ATL仅仅给我们提供了一些简单的窗口类, 以前写ActiveX控件写点界面还真是很难,现在有了它不用发愁了。WTL是都是模板所以效率高体积小,现在越来越多的人都在用它。WTL不仅封装了通用的窗口和控件,而且把GDI也向MFC一样封装了一遍,但是和MFC不同的是,WTL封装的这套GDI类底层画法不仅仅使只用gdi的api,它竟然还用到了OpenGL,那天我在源代码中发现了一些OpenGL库的引用使我惊奇万分?至于为什么要这么做,我还没有找到确切的答案。 下面是AtlGdi.h的一段代码: // required libraries #if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE)   #pragma comment(lib, "msimg32.lib") #endif // !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) #if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE)   #pragma comment(lib, "opengl32.lib")                                                                  //这里加上了OpenGL的库 #endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) //看看下面的类名是不是很熟悉呢?hoho /// // Classes in this file: // // CPenT<t_bManaged> // CBrushT<t_bManaged> // CLogFont // CFontT<t_bManaged> // CBitmapT<t_bManaged> // CPaletteT<t_bManaged> // CRgnT<t_bManaged> // CDCT<t_bManaged> // CPaintDC // CClientDC // CWindowDC // CMemoryDC // CEnhMetaFileInfo // CEnhMetaFileT<t_bManaged> // CEnhMetaFileDC // // Global functions: //   AtlGetBitmapResourceInfo() //   AtlGetBitmapResourceBitsPerPixel() //   AtlIsAlphaBitmapResource() //   AtlIsDib16() //   AtlGetDibColorTableSize() //   AtlGetDibNumColors(), //   AtlGetDibBitmap() //   AtlCopyBitmap() //   AtlCreatePackedDib16() //   AtlSetClipboardDib16() //   AtlGetClipboardDib() WTL8.0一共只有19个头文件     atlapp.hmessage loop, interfaces, general app stuff    atlcrack.hmessage cracker macros    atlctrls.hstandard and common control classes    atlctrlw.hcommand bar class    atlctrlx.hbitmap button, check list view, and other controls    atlddx.hdata exchange for dialogs and windows    atldlgs.hcommon dialog classes, property sheet and page classes    atlframe.hframe window classes, MDI, update UI classes    atlgdi.hDC classes, GDI object classes    atlmisc.hWTL ports of CPoint, CRect, CSize, CString, etc.    atlprint.hprinting and print preview    atlres.hstandard resource IDs    atlresce.hstandard resource IDs for Windows CE    atlscrl.hscrollable windows    atlsplit.hsplitter windows    atltheme.hWindows XP theme classes    atluser.hmenu class, USER object classes    atlwince.hspecific support for Windows CE    atlwinx.hextensions of ATL windowing support  上面这些东西,对我们来说已经够用了,一些关于窗口和控件的封装代码写的很简单就是每个方法对应一个api或者消息,如果我们认真的去读它的代码也会有不少收益,以后我会跳一些好的代码分析一下. WTL8.0 提供了向导,用法很简单下载一个WTL8.0的库,里面都带着 AppWiz,在 AppWiz/目录下双击相应的向导js就可以了。作者:wangweixing2000 转载请注明出处!

    最新回复(0)