First knowledge of WTL (PART I)

Source: Internet
Author: User

The code-run effect is shown below:

In the next section, we add a button to the SDI to demonstrate a pop-up dialog box that we added.

Because WTL currently does not support class Wizard like MFC, we have to add some code manually. First we insert Dialog in Resource View, and then we can also borrow the MFC class Wizard, as shown in the figure:

CAxDialogImpl here is also Cdialogimpl,mfc Class Wizard did not make some contribution to our small program, in addition to generating. h and. cpp files, I believe that WTL can also have Class wizard support. Don't forget to add #include "resource.h" to your. h file to add your code in reference to Aboutdlg. Here I mainly introduce how to use the DDX/DDV mechanism in the WTL, if you know the DDX/DDV in MFC, this is so for you easy!

First, you add in the header file

(1) #include <atlddx.h> //对使用DDX/DDV macro的定义
#include <atlcom.h>
#include <atlhost.h>  //这两个文件是使对话框可以使用ActiveX控件
(2) class CDlgTest : public CAxDialogImpl<CDlgTest>,
public CWinDataExchange<CDlgTest>//封装了DDX/DDV运行机制
(3) Add macros: BEGIN_DDX_MAP(CDlgTest)
DDX_CONTROL(IDC_TREE_WTL, m_Tree) // m_Tree我们自己定义的一个控件
END_DDX_MAP()
these are similar to the basic MFC, and finally add DoDataExchange (false) in the OnInitDialog, the same as MFC to complete the DDX/DDV. In addition, in the dialog box added a menu, add methods and MFC, you can also add code in the program to complete!

References: WTL for MFC Programmers Author: Michael Dunn here to thank

This article supporting source code

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.