What is ActiveX
- "VC Master"
ActiveX is an OCX's advanced form (maybe it is more simple in the simple form of OLE). However, this simple definition cannot express the essence of the ActiveX control, and the user thinks that ActiveX is OL. For programmers, ActiveX is also a real-world technology for Internet. It provides an information exchange method in the past. One of the main differences of OCX and ActiveX controls is that ActiveX controls are usually smaller (light).
Creating an ActiveX control with Visual C : ATL and MFC. There is indeed no reason to say, in a given situation, which way to create controls is to make it clear: What do you expect to do, what you intend to develop, And your expertise level. Obviously, in some cases, the creation of controls is better than another method, because the two methods do have advantageous disadvantages. When a AtlactiveX control is compared with an MFC ActiveX control, you need to consider some factors. In order to give you some basic views of this issue, please read the attention list below, from here, you will find some of you. Basic ideas, thereby helping you choose a best solution.
Development Speed: Using the MFC ActiveX Control Wizard (MFC ActiveX Control Generation Wizard) is the fastest way to create a control. This wizard manages most of the interface details so that you will eventually get a contour of the logic. In fact, using the ATL method to create a control usually to make the developer use twice the time (in the MFC method). Obviously, this also depends on factors such as control complexity and programming experience.
Maintenance: A total of MFC and ATLs is to make the code they generated, which is much easier than those written from the beginning. However, when making some changes related to maintenance (for example, if you find a small problem, modify it), you should consider it. ATL controls typically contains not much "boiler steel sheet" (ie, unknown) code generated by the wizard. Because the code written by yourself is more familiar, it is more easier to change. On the other hand, Microsoft maintains all controls in the MFC you are using, which means that many small problems corrections and other types of updates, as long as they are easily compiled once, they can be automatically completed automatically. In this case, what choices do, really difficult to answer, because there is no way to determine what maintenance changes in future controls you need to your control.
Control Size: If you want to create the smallest ActiveX control, then take the ATL scheme. ATL leaves all aspects of control of the control to you, making it easy to handle each element of the control, not in the mud talents of the MFC special code. The MFC-based control is not only large, but also the MFC library must be downloaded before the user uses this control. This library also has quite a few code.
Learning difficulty: Since more things (such as interface) have to be considered when creating an ATL control, it is more difficult to create more than the MFC control. In most cases, first create several controls with the MFC ActiveX ControlWizard (MFC ActiveX Control Generation Wizard), which is worthwhile to create a rule of the control logic.
Define a specific ActiveX control which rules must be remembered:
u Keeping code miniaturization, experience tells us that the volume of the ActiveX control should be below 40KB. Usually users don't want to download huge, only controls for moving with page graphics. When there is no way, a large component is divided into several small functional blocks. (Skills) The compressed CAB file can also reduce the download size. u Use the least lasting data, lasting data not only increase the load time and memory requirements, but also expand the size of the control itself.
u Limit functionality at a minimum, when writing OCX for the local machine, several additional features do not increase what problems, but the transmission time is indeed a big problem.
u Function Single is the key, one of the original motives of the establishment is to store a large amount of pre-compiled function calls with easy access. As the Seniors of OCX, the reason for the existence of DLL is here. You will find that many OCXs on the market (such as DLL) do not stop containing an object (such as button). In fact they contain a cluster object. This strategy is of course very good for the desktop system, but it will not pass on the Internet. To ensure that you keep an object in one control. Follow the principle to modular control to ensure that users do not have to download things that must definitely need functions.