WTL for MFC Programmers (2)

zhaozj2021-02-08  260

Introduction to the Series

WTL rocks. It does. It has a lot of the power of MFC's GUI classes, yet produces substantially smaller executables. If you're like me, and learned GUI programming with MFC, you've become quite comfortable with all the control wrappers MFC provides, as well as with the flexible message handling built into MFC. If you're also like me and do not relish the idea of ​​several hundred K of MFC framework getting added to your programs, WTL is for you. However, there are A Few Barriers We Have to overcome:

WTL has functions of a GUI class similar to MFC, and can also generate a sufficiently small executable. If you use MFC to make GUI programming, you are very accustomed to using the control of the MFC package, flexible use of the MFC's message; if you are like me, don't want MFC hundreds of framework program released with your program Then, the WTL will be suitable for you. However, we must also overcome some difficulties:

ATL-Style Templates Look Weird At First.

No ClassWizard Support, So Writing Message Maps Involves Some Manual Labor.

No Documentation In MSDN, You NEED TO FIND ITHEWHERE ELSE, OR EVEN LOOK AT The WTL SOURCE.

No reference books you can buy and keep on your shelf.

IT HAS That "Not Officially Supported by Microsoft" Stigma

ATL / WTL WINDOWING IS SUFFICIENTLY DIFFERENT FROM MFC Windowing That Not All your knowledge. First, the ATL style template looks weird.

Without the support of the type wizard, all event mappings need to be handwritten.

There is no document like MSDN, often need to refer to the source code of the WTL.

There is no reference book that can be purchased.

Microsoft does not provide official support.

ATL / WTL forms and MFC have a huge difference.

On the Other Hand, The Benefits of WTL Are:

On the other hand, the advantage of WTL is:

No Complex Doc / View Framework to Learn Or Work Around.

Has Some Essential UI Features from MFC, Like DDX / DDV AND "Update Command UI" FunctionAlity.

Actually Improves on Some MFC Features (E.G., More Flexible Splitter Windows)

Much Smaller Executables Compared to a staticly-linked mfc app.

You can apply bug fixes to WTL yourself and not affect existing apps (compare this with replacing the MFC / CRT DLLs to fix a bug in one app, and having other apps break) If you still need MFC, MFC and ATL / WTL windows can co-exist peacefully (for a prototype at work, I ended up creating an MFC CFrameWnd that contained a WTL CSplitterWindow, which contained MFC CDialogs - that was not me showing off, it was modifying existing MFC code but using the nicer WTL splitter ).

There is no complex document / view framework to learn and work.

Provides the essential characteristics of the MFC UI, such as DDX / DDV and UI updates.

In fact, certain features of the MFC are improved, such as more variable segmentation forms.

A smaller executable more than the MFC static connection.

You can locate bugs yourself in WTL, without affecting existing projects (relative to location bugs in the MFC / CRT DLL, will interrupt other programs)

If you still need MFC, ATL / WTL can be mixed with the MFC (I have generated a MFC CFraMewnd, which sets a WTL CSPLitterWindow class containing the MFC CDialog class, by doing this, I use more beautiful WTL splitting replacement Existing code in MFC

In this series, I will first introduce the ATL windowing classes. WTL is, after all, a set of add-on classes to ATL, so a good understanding of ATL windowing is essential. Once I've covered that, I'll introduce WTL Features and show how the make gui programming a lot easier.

In this series, I will first introduce the form class of the ATL. Since the WTL is actually a set of ATL extensions, it is important to fully understand the ATL form class. After that, I will introduce the characteristics of WTL and how to use them to simplify GUI programming.

Introduction to Part I

WTL ROCKS. But Before get to why, we need to cover atl first, wtl is a set of add-on classes to atl, and if you've been strictly an mfc program in the paste, you May never have enchantered the ATL GUI classes. So please bear with me if I don't get to wtl right off the ba; the detour.

We need to know ATL before we understand the WTL. Since WTL is a set of ATL's extended classes, and if you are previously a complete MFC programmer, you may never have access to the ATL GUI class. So please forgive me, I didn't tell WTL directly because the ATL is important.

In this first part, I will give a little background on ATL, cover some essential points you need to know before writing ATL code, quickly explain those funky ATL templates, and cover the basic ATL windowing classes. In the first part, I will give A little ATL's knowledge tells some basic points you need to know before writing ATL code, and quickly instructs those ATL templates that make people feel the heartbeat and reveal the basic ATL form.

ATL Background

ATL and WTL HISTORY

The Active Template Library ... kind of an odd name, is not it? Old-timers might remember that it was originally the ActiveX Template Library, which is a more accurate name, since ATL's goal is to make writing COM objects and ActiveX controls easier. (ATL was also developed during the time that Microsoft was naming new products ActiveX-something, just as new products nowadays are called something.NET.) Since ATL is really about writing COM objects, it only has the most basic of GUI .

Active Template Library seems unlike a fixed name, its more exact name should be ActiveX Templete Library. Originally used to simplify COM and ActiveX programming (during ATL development, Microsoft's new product is called ActiveX, and now this product is called .NET) When ATL real application After COM programming, he only provides the most basic The GUI class is like the CWND and CDIALOG of the MFC. Fortunately, these GUI's flexibility is enough to build class libraries like WTL.

WTL is currently in its second revision. The first was version 3.1, and the second is version 7. (The version numbers were chosen to match the ATL version numbers, that's why they're not 1 and 2.) Version 3.1 works with VC 6 and VC 7, although you need to define a couple of preprocessor symbols for VC 7. WTL version 7 is a drop-in replacement for version 3.1, and works without modification on VC 7, so there really is no reason to use 3.1 for The current version of New Development.wtl is his 2nd version. The first version is 3.1, and the second version is 7. (This version is defined with the version number of the ATL. It is not a continuous) version 3.1 can be operated on VC6 and VC7, but you need to define a pair of preprocessing programs for VC7. The WTL 7 version has been improved on the basis of version 3.1, and there is no change in the upper part of VC7, so there is no reason to use the 3.1 version of the new program.

(Now the latest version of WTL is 7.1 --- Snail Hand)

转载请注明原文地址:https://www.9cbs.com/read-1182.html

New Post(0)