Wtl developer Guide Chapter 2 wtl Overview

Source: Internet
Author: User

Wtl developer Guide Chapter 2 wtl Overview

 

 
Wtl developer Guide

Note: This article is translated by Yuan Xiaohui Based on Eamon o 'tuathail's wtl developer's Guide (www. clipcode. Biz) and published on www.farproc.com and blog.csdn.net. This article is only intended for myself and other wtl fans, and is not intended for commercial purposes. You can repost this article, but you must ensure the integrity of this article and keep this statement!

Chapter 2 wtl Overview

Target

The goal of this chapter is:

Ÿ wtl's position in the whole VC ++ Development
Objective of ipvwtl
Ÿ wtl and other user interface (UI) development technology comparison
Introduction to wtl Installation
Introduction to what wtl has installed
Lists available development resources.
Introduction to the following chapters

Overview

In the past, Visual C ++ developers often used MFC, because it provided a wide range of programming technology fields, while the fields involved in the template library were relatively narrow.

Recently, the fields and quality of the template library have been greatly improved, so more and more people have chosen the template library.

The objective of the ATL design is to provide fast and compact COM components. The STL of Iso c ++ provides collection, VC ++ ole db data consumer and provider templates to provide database support. Correspondingly, MFC provides a C ++ class library, which supports COM creation, Collection class, database, and user interface.

Most senior developers prefer the new template development method. MFC is very large, bloated, unfriendly to threads, and basically out of date! The template method is fast (when correctly designed), flexible, and covers all the latest technologies. It is no better to deal with new development needs.

So far, the main headache for template enthusiasts is how to create a graphical user interface (GUI ). ATL does provide a lightweight Win32/64 wing packaging class, but it does not cover all UI requirements. ATL developers have to re-program the MFC ui or use VB to front-end their atl com for trivial user interface processing. Neither of these two methods is completely satisfactory.

Go to the topic and start to talk about the windows template library ). Wtl is an advanced set of packages and easy-to-use enhancement templates built on Win32/64 APIs. It provides extensive support for graphic user interfaces. Wtl not only keeps the real lineage of the template library, it is small, fast, non-invasive, but also includes the latest UI concepts and supports multithreading very well. You can use wtl separately or together with ATL, STL, VC ++ data templates, third-party class libraries, and your own class libraries to take advantage of their respective advantages. Wtl usually does not rely on external DLLs. If you use wtl for developmentProgramOnly one EXE file can be provided to the end user.

Wtl goals

Wtl is applied to user interfaces like ATL to com and STL to collection. Like its cousin, wtl takes some time to learn, but once mastered, there is no better way to develop advanced programs than it. In essence, wtl has completed three major tasks:

Provides an application framework (framwork)

Integrates UI Functions

Windows controls, system dialog boxes, and GDI objects are encapsulated.

Let's look at them one by one.

Provides an application framework

Wtl provides a lightweight and extensive application framework that provides very valuable tools for its programs. Its goal is neither as hard to understand as the MFC framework nor as primitive as manual winmain writing.

Wtl contains a series of C ++ templates and a wtl Appwizard. Appwizard raises several questions to the program developers and then produces the VC ++ project and program accordingly.Source code, SourceCodeMost of them are instances or inheritance classes of the wtl template class. In general, developers only need to change the code produced by Appwizard, and the "sample" code that rarely needs to be modified is encapsulated by the wtl template.

Wtl has a class for managing the entire module (a DLL or EXE). This class is instantiated in the code generated by Appwizard and is initialized and terminated in the automatically generated winmain. A wtl program can also be used as a COM server and supports programmable applications. Wtl provides a message processing mechanism that supports message filtering and On-idle functions. change notifications caused by wm_settingchange can also be intercepted.

MFC provides a "document-framework-View" structure. wtl also provides a framework (such as a top-level window that includes menu bar, toolbar, and status bar) and a view, however, documents are not supported at all. The MFC method often hinders advanced developers. Its documentation is serialized based on binary data. In today's Internet world, XML/XSL-based document formats are becoming increasingly popular, and there are more and more demands for flexible storage mechanisms (which may not be stored on a local disk at all). Documents may need to use a large number of remote mechanisms, for example, WebDAV and FTP. Wtl does not provide any functions or mechanisms for data or storage formats. program developers can write their own code, for example, you can use the efficient Win32 API writefilegather/readfilescatter or XML parser to do this as needed.

Wtl supports dialog box-based programs, Single Document Interface (SDI), and multi-Document Interface (MDI ). SDI also supports multi-threaded SDI. Every SDI window has one thread. Most advanced applications may use this architecture (for example, the Word2000 method is imitated ). Wtl does not support the multi-thread MDI architecture, that is, it does not support a mid sub-window and a thread, but this is understandable. For example, this can avoid many problems between the thread and the MDI parent and child windows.

Integrates UI Functions

Wtl provides a set of essential features for implementing modern user interfaces.

Wtl provides a framework window for managing a rebar containing a command bar (enhanced menu bar), tool bar, a status bar, one or more views ). A view can be based on controls such as a common empty window recheidt, listview, and Treeview. If multiple views are used, the splitting function of wtl comes in handy, and views also support scrolling. the status bar can be a pane or multiple panes.

Wtl also supports the traditional menu bar and toolbar, but its main menu concept is based on the command bar. A command bar can contain menus and toolbar icons, which can be displayed in a rebar and moved around. If a menu item and a toolbar button have the same command ID, the corresponding icon is automatically displayed next to the menu item. Wtl supports command lines that can be parked or float. wtl command lines are similar to those in Internet Explorer but different from those in Word2000 or Visual Studio (more desirable, wtl does not support hiding menus of infrequently used projects (such as Word2000 ). The concept of Dynamic Data Exchange allows two-way data transmission between visible UI controls and C ++ data members, which is similar to the DDX of MFC. You can use ATL to generate a dialog box, including those that support ActiveX controls and window containers. The resource view of Visual C ++ can be used to layout standard controls, common controls, and ActiveX controls on the dialog box resources, use ATL window message handler Wizard to map the messages of these controls.

Wtl provides templates used to manage attributes, create Attribute pages, and create wizard.

The printer device scenario, print preview, devmode processing, and print job management functions can be used to print documents.

You can use special device scenarios, file managers, and Enhanced Metafile information classes to support Enhanced Metafile.

Windows controls, system dialog boxes, and GDI objects are encapsulated.

ATL provides control over normal windows, but does not provide special support for Windows based on different window classes. Developers have to manually write snedmessage calls as needed. For communication with edit or Treeview, they have to use ATL cwindow and call Win32 sendmessage to use em_limittext or vm_setitem. They also have to worry about whether the message parameters are correct (sendmessage has no type check, all of which are wparam, lparam ). When the program receives them, it is also "Raw data"-wparam and lparam are sent to the message queue, and the data must be converted to the appropriate type through code, at this time, we must ensure that the conversion is correct for each message.

Some ATL developers use the code extracted from the atlcon routine, which provides encapsulation of Windows UI elements. Wtl now and has evolved a wide set of encapsulation classes that implement encapsulation of all standard and general window controls, system dialogs, all GDI objects, and others. In wtl, whether it is for edit, button, ListBox, Treeview, listview, or general file dialog box, color dialog box, font dialog box, or DC, pen, brush, region, font and so on all have corresponding packaging classes.

In addition, wtl provides a complete set of message crackers. The messages in the window are mapped to the specified processing function. When ATL is used, the message processing function receives lparam and wparam, and wtl message cracker is used. The parameters of the message processing function are specific types of messages. For example, a wm_lbuttondown message has a cpoint-type parameter (cpoint is the packaging of wtl for the Win32 point structure-wtl encapsulates each common structure ). Note: The ATL Windows message handler wizard uses the original message ing of ATL. For non-wtl message crackers, the next version of VC ++ may support the wizard better.

Many developers choose MFC only to use cstring. wtl also provides cstring implementation, which is almost the same as that of MFC. Wtl cstring supports ASCII, MBCS, Unicode, and automated BSTR. It supports mutual conversion between these types, string connection, truncation, and comparison, and supports the same formatting as printf, supports flexible memory management.

Relationship between wtl, ATL and Win32/64 APIs

Wtl is based on ATL, Win32, and 64api, and ATL is based on Win32/64 API. When talking about the relationship between them, we should discuss it from the source code and binary perspectives.

Source code

Win32/64 APIs are a collection of hundreds of C functions, covering a large range, including the COM and wing we are interested in.

ATL is a set of C ++ templates, which are almost customized for COM programming. However, it also supports a wide range of underlying indexing wing functions.

Wtl is a set of C ++ templates. Its focus is on the advanced indexing wing function. wtl does not depend on com, but can be used with COM. Coinitialize is not called as long as you choose to support "COM server" in wtl.

Wtl uses the indexing wing service of ATL, so to use wtl, you must access the ATL template.

ATL calls Win32/64 API, wtl calls ATL template and Win32/64 API, your program code calls wtl, ATL and Win32/64 API.

When you run wtl Appwizard, it generates some source files for you. These source files will become part of your program code. The generated code calls wtl to build the program framework.

Wtl supports Windows 2000, Windows ME, Windows NT4, Windows 98, Windows 95, OSR 2, and "classic" Windows 95. wtl does not only support "minimum public Denominator ", instead, the # define (such as _ richedit_ver, _ win32_ie, _ win32_winnt and winver) is provided to determine the Win32/64 features. Wtl does not automatically identify the version of the installed operating system or the version of IE (for example, it does not use loadlibrary/getproceaddress or getversionex APIs ). The program developer must specify the # define macro and assume that the program runs properly on the client of the correct version during compilation. Otherwise, the program cannot.

For example, if a command bar is intercepted for a short time due to a window size change, do not "cut" the command lines that exceed the window boundary.

The V-type symbol is a sign that contains two greater signs. when pressed, a menu is displayed that contains the items intercepted from the end of the command bar due to the window size change. If ie5 is included, the V-type symbol is supported. Otherwise, it is not supported.

In the wtl program, if _ win32_ie is not defined as 0x0500 or higher (for example, in stdafxh), the V-type symbol is displayed when necessary.

Binary

ATL and wtl are published as a set of header files containing the C ++ template. There are a few classes in ATL that can be used as an independent DLL, but most programmers also include their source code in their own projects. For wtl programs, this is also recommended. Wtl does not have anything that can be used as an independent DLL, so the C ++ class (not all) of wtl will be included in each program. When you compile the wtl program, you will eventually get an EXE or DLL. This is the only program you need to deliver to the end user. It does not depend on the external library. Of course, except for the DLL that comes with the operating system, for example, kernel32.dll, but these libraries basically exist (if not, Windows itself may not work properly ). One exception: If you need to use floating point numbers, you have to use the C Language Runtime Library (CRT ).

Selection of WTL-ATL, MFC, VB, Java, DHTML, etc.

...... (Hundreds of words without nonsense)

Why choose wtl?

Wtl is not as bulky as MFC, and the final application is also relatively small. For advanced programs, wtl gives you the opportunity to use APIs, But it saves time than pure API programming.

Win32 APIs can be used directly, but sometimes they seem quite independent and it is difficult to decide how to combine them for use.

Wtl provides more functions to perform the same operation.

Since the called method is determined during the compilation period rather than the runtime period, it has an advantage in efficiency and code scale, and the template library is becoming increasingly popular.

Install wtl

As wtl develops rapidly, its publishing mechanism is also changing frequently.

Future release Model

It is very likely that the next version of VC ++ will be integrated into wtl upon release. Therefore, it may be automatically installed together with ATL, STL, and data templates.

Current installation mechanism

Currently, wtl is released as part of Microsoft platform SDK (January 2000 or higher). You need to manually install it in three steps, which may be automatically completed in the future.

Step 1-get a file

You can get the installation file from the third or http://msdn.microsoft.com on the msdn disc. You can choose to install this SDK all or install only the part that contains the Windows template library. (You can also download the wtl7.1 installation package at www.farproc.com)

Note: The subsequent steps of wtl7.1 installation are different from those of the original text. Therefore, the installation of wtl7.1 is not translated as the original text.

Step 2-wtl Appwizard

After installation, open the wtl installation directory (such as C:/program files/Microsoft platform SDK) to enter the corresponding appwizxx directory, where XX is your VC version number, for example, if you use vc6.0, you can access appwiz60. You will see a setup. JS file, click Run it to automatically install wtl Appwizard for you. If you cannot run this file or want to manually install it, copy atlapp60.awx to "... The/Microsoft Visual Studio/common/msdev98/template directory is also supported.

Open VC, and you can see the "ATL/wtl Appwizard" option in the new dialog box.

Step 3-Update PATH

Step 3 is to set the path so that the compiler can find the wtl header file. Wtl is a header file containing c ++ (No. CPP file). During compilation, the compiler needs to find these files under the wtl installation directory/src/wtl/include, you can include this full path in your source file (not recommended, but also), or add this path to VC's "include files", as shown in

What is wtl installed?

After wtl is installed, there will be one or several appwizxx directories, which are the location of the wtl Appwizard file; one include directory is the header file of wtl (that is, the source file); and one samples, examples of some wtl programs.

<To be continued>
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.