Talking about ATL (1)

zhaozj2021-02-08  430

Talking about ATL (1)

As a small bamboo of ATL / COM / ACTIVEX, I really want to improve our places, write some articles to attract more people who want to learn COM. Every day, some novices will have problems with parameter transmission such as custom structural types, arguments, and interfaces. This article mainly makes some newcomers who are afraid of COM know what basic knowledge, let them know what to do with COM components, make them a probably aware of ATL.

What is ATL?

ATL (Event Template Library, Active Template Library is a template library designed to develop COM components. The current version is ATL7.1 (with .NET released), it modified the first version ATL3.0 (with Visual C 6.0) Publish) some bugs.

Learning ATL need for background knowledge?

1, COM foundation. Because ATL is for COM, solid COM knowledge can help you. It is best to see "COM Nature".

2, C template knowledge.

3, Windows basic knowledge, especially the knowledge about the window part in Win32. Because ATL is very shallow to the user interface (UI) package, it is often created a form and handles a message to be more complicated than MFC.

4, STL knowledge. ATL and STL have in communication on data collection management, if you have STL to make the foundation, then understand the collection and enumeration in the ATL should be relaxed.

How to see ATL?

There is a certain basic C programmer has used STL, which saves us a lot of time it gives us Vector, List, Queue, etc., and some generic algorithms. In the past, some people may have some doubts about it, but he got our affirmation now. ATL corresponds to COM, although it is just out, BUG is now, the BUG of ATL7.1 is rare! We can use it with confidence. Some people must have seen Don Box's "COM Nature". After reading, I will definitely say that I have written a COM component so trouble! The most important thing is to pay attention to the reference count, and there are so many unclear GUIDs. Even just learning COM doesn't know how to create a new Guid, don't know what they are all. Not to mention, I have to create a class factory. This stuff may take a group of people who want to learn COM. CoM is also very small. There are several good books to talk about theory knowledge. An example is simply a tiger! If you create a component or control with ATL is very simple, you can complete it in a width, haha! There is a "in-depth analysis of ATL" this book worth watching. Some people will definitely say that MFC can also create a control, right, if you want to go deep into the end, it is still more to use ATL it will make you more mastery of COM. I am using ATL7.1 to do components, can be supported by VB6, VC7 without adding any .NET library.

Where is the shortcoming of ATL?

ATL's disadvantages are supported by the form, which only encapsulates the most basic feature, almost all controls are completed through the API of the Win32 window. I will have a bitter, and I have to create a Combox that may have to waste some time. But this can also make you experience the use of API to create pleasure (flexibility). If you want to make a component or a development package, you should do not with the interface unless you have. Don't have the benefits of the form, one is flexible, customers can write interfaces according to their own style (customers hate hate the hate dialogs and weird buttons, etc.). Another benefit is that if your development package is a pure interface (no interface interface), it can be easily passed between the custom structure between the interfaces. I have seen many other people write control (or COM components), call an interface method for more than a dozen parameters, and let customers spend a long time to learn its document (because their parameters are inexplicable, EG: CREATE (BSTR STR)) . We have made the control or COM development package is to use it to customers, but we must also ensure that it is easy to flexibly, try to make customers can use the point. I think many people are willing to use custom buildings! Because it can be directly defined directly on the client. However, everyone should pay attention to the transmission structure, whether it is [in] or [out] attribute to pass the pointer, the reason is very simple, INTERFACE can be said to be Struct (of course, it is different). Interface is virtual and Struct is not. Write here first, the next article will speak something actually. If you are not right, please ask prawn, we discuss together. My MSN: Wangweixing2003 @ Hotmail.

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

New Post(0)