Windows Development with C + +: Windows Template Library 8.0

Source: Internet
Author: User
Tags new features microsoft download center

Directory

Task dialog box

Aero Wizard

New File dialog box

Other WTL functions to be explored

The developer responsible for Windows®template library (WTL) recently released the latest version, which is excellent and fully supports almost any new user interface features and enhancements introduced with Windows vista®. This month, I will focus on some of the new features in this latest release. If you are not yet familiar with WTL and its adaptation to the Visual c++® development field, I will briefly introduce it at the beginning.

The Visual C + + team developed the Activity Template Library (ATL) in order to be able to easily create COM clients and servers while generating the smallest, fastest code possible. Unlike MFC, ATL supports COM development from the very beginning of design and is doing well, while MFC focuses on developing user interface applications and only adds support for COM later. ATL only supports basic user interface development, but it provides classes that can be used as lightweight building blocks and base classes for more advanced user interface libraries.

WTL has extended ATL to provide a large number of class templates for building applications, how simple you want to be, how complex it can be. WTL is not provided with Visual C + +, but can be obtained through the SourceForge Web site SOURCEFORGE.NET/PROJECTS/WTL and the Microsoft Download Center.

The main development focus of WTL 8.0 is Windows Vista UI support, so I'll talk about some of the topics I've discussed in previous columns and articles. However, this month's focus is on how WTL's latest improvements will facilitate the adoption of these new features and ensure further reductions in the code you need to write yourself! The MSDN® Magazine website provides downloads of this column, and downloads provide examples of most of the features described in this article.

Task dialog box

The Task dialog box is one of my favorite new features in Windows Vista, providing a powerful API that allows you to develop simple dialogs and advanced dialog boxes with a little effort.

The TaskDialogIndirect function and the TASKDIALOGCONFIG structure can be daunting and do need some help from C + + to simplify its use. WTL provides support for task dialogs through the Ctaskdialogimpl base class template. The Ctaskdialogimpl class uses the Ctaskdialogconfig class internally to encapsulate the taskdialogconfig structure. If you need to access the structure directly, you can access it through the public variable M_TDC, but you are unlikely to need it because the Ctaskdialogimpl class provides the appropriate member functions to package it, which is excellent. Also provided are CTaskDialog specific classes derived from Ctaskdialogimpl for very simple situations, but generally it is best to derive a class from Ctaskdialogimpl to implement the Task dialog box.

Figure 1 shows some of the task dialog box features and how to use them in WTL. The example sets the window caption, the primary description, and the content text description. The Task dialog box supports multiple additional text descriptions, but you need to use different mechanisms to set these text descriptions based on whether or not you have constructed a task dialog box. Unfortunately, the Ctaskdialogimpl class doesn't generalize these differences, making it a bit confusing to update these text descriptions. Figure 2, based on whether the text description was set before or after the Task dialog box is constructed, outlines how to use the Ctaskdialogimpl class to set various text descriptions. A common way to update these instructions is to use the pre-built method in the constructor of the Task dialog box and use the post-construction method in various event handlers.

Figure2 Update Task dialog box description

Text description Pre-constructed Post Construction
Window title Setwindowtitle () :: SetWindowText ()
Main notes Setmaininstructiontext () SetElementText (tde_main_instruction, ...)
Specific content Setcontenttext () SetElementText (tde_content, ...)
Footnote SetFooterText () SetElementText (Tde_footer, ...)
Expanded information Setexpandedinformationtext () SetElementText (tde_expanded_information, ...)
Expanded control text Setexpandedcontroltext () N/A
Collapsed control text Setcollapsedcontroltext () N/A
Verify Setverificationtext () N/A

Figure1 Task dialog Box sample

enum
{
  Button_Save = 101,
  Button_DontSave,
};
class SampleDialog : public CTaskDialogImpl<SampleDialog>
{
public:
  SampleDialog()
  {
    SetWindowTitle(L"Title");
    SetMainInstructionText(L"Main instruction");
    SetContentText(L"Content");
    ModifyFlags(0, TDF_ALLOW_DIALOG_CANCELLATION |
            TDF_USE_COMMAND_LINKS);
    static TASKDIALOG_BUTTON buttons[] =
    {
      { Button_Save, L"&Save", },
      { Button_DontSave, L"Do&n't save", },
    };
    SetButtons(buttons,
          _countof(buttons));
  }
};

Figure 1 Example of a task dialog box

Related Article

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.