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