Click here to Skip to main content
15,881,413 members
Articles / Desktop Programming / WTL

TDXML: XML-Based Task Dialogs with a Visual Task Dialog Editor

Rate me:
Please Sign up or sign in to vote.
4.92/5 (67 votes)
19 Mar 200713 min read 99.8K   1.4K   90  
A library and a visual editor that make it easy to build task dialogs and use them in your C++ applications
#ifndef TEXTTOOLSPAGE_H_INCLUDED
#define TEXTTOOLSPAGE_H_INCLUDED

/////////////////////////////////////////////////////////////////////////////

class CTextToolsPage : public CDialogImpl<CTextToolsPage>,
                       public CWinDataExchange<CTextToolsPage>
{
public:
    enum { IDD = IDD_TEXT_TOOLS };

    // Construction
    CTextToolsPage();
    ~CTextToolsPage();

    // Maps
    BEGIN_MSG_MAP(CTextToolsPage)
        MSG_WM_INITDIALOG(OnInitDialog)
        COMMAND_HANDLER_EX(IDC_USE_CAPTION_TEXT, BN_CLICKED, OnUseCaptionText)
        COMMAND_HANDLER_EX(IDC_USE_FOOTER_TEXT, BN_CLICKED, OnUseFooterText)
        COMMAND_HANDLER_EX(IDC_USE_EXPANDED_TEXT, BN_CLICKED, OnUseExpandedText)
        COMMAND_HANDLER_EX(IDC_USE_EXPANDO_COLLAPSED_TEXT, BN_CLICKED, OnUseExpandoCollapsedText)
        COMMAND_HANDLER_EX(IDC_USE_EXPANDO_EXPANDED_TEXT, BN_CLICKED, OnUseExpandoExpandedText)
        COMMAND_HANDLER_EX(IDC_USE_CHECKBOX, BN_CLICKED, OnUseCheckbox)
        COMMAND_HANDLER_EX(IDC_CAPTION_TEXT, EN_CHANGE, OnCaptionTextChanged)
        COMMAND_HANDLER_EX(IDC_MAIN_TEXT, EN_CHANGE, OnMainTextChanged)
        COMMAND_HANDLER_EX(IDC_MAIN_ICON_COMBO, CBN_SELCHANGE, OnMainIconSelchange)
        COMMAND_HANDLER_EX(IDC_CONTENT_TEXT, EN_CHANGE, OnContentTextChanged)
        COMMAND_HANDLER_EX(IDC_FOOTER_TEXT, EN_CHANGE, OnFooterTextChanged)
        COMMAND_HANDLER_EX(IDC_FOOTER_ICON_COMBO, CBN_SELCHANGE, OnFooterIconSelchange)
        COMMAND_HANDLER_EX(IDC_EXPANDED_TEXT, EN_CHANGE, OnExpandedTextChanged)
        COMMAND_HANDLER_EX(IDC_EXPANDO_COLLAPSED_TEXT, EN_CHANGE, OnExpandoCollapsedTextChanged)
        COMMAND_HANDLER_EX(IDC_EXPANDO_EXPANDED_TEXT, EN_CHANGE, OnExpandoExpandedTextChanged)
        COMMAND_HANDLER_EX(IDC_CHECKBOX_TEXT, EN_CHANGE, OnCheckboxTextChanged)
    END_MSG_MAP()

    BEGIN_DDX_MAP(CTextToolsPage)
        DDX_TEXT(IDC_CAPTION_TEXT, m_sCaption)
        DDX_TEXT(IDC_MAIN_TEXT, m_sMainInstruction)
        DDX_TEXT(IDC_CONTENT_TEXT, m_sContent)
        DDX_TEXT(IDC_FOOTER_TEXT, m_sFooter)
        DDX_TEXT(IDC_EXPANDED_TEXT, m_sExpandedText)
        DDX_TEXT(IDC_EXPANDO_COLLAPSED_TEXT, m_sExpandoCollapsed)
        DDX_TEXT(IDC_EXPANDO_EXPANDED_TEXT, m_sExpandoExpanded)
        DDX_TEXT(IDC_CHECKBOX_TEXT, m_sCheckbox)
        DDX_CHECK(IDC_USE_CAPTION_TEXT, m_bUseCaption)
        DDX_CHECK(IDC_USE_FOOTER_TEXT, m_bUseFooter)
        DDX_CHECK(IDC_USE_EXPANDED_TEXT, m_bUseExpandedText)
        DDX_CHECK(IDC_USE_EXPANDO_COLLAPSED_TEXT, m_bUseExpandoCollapsedText)
        DDX_CHECK(IDC_USE_EXPANDO_EXPANDED_TEXT, m_bUseExpandoExpandedText)
        DDX_CHECK(IDC_USE_CHECKBOX, m_bUseCheckbox)
        DDX_CONTROL_HANDLE(IDC_MAIN_ICON_COMBO, m_wndMainIcon)
        DDX_CONTROL_HANDLE(IDC_FOOTER_ICON_COMBO, m_wndFooterIcon)
    END_DDX_MAP()

    // Message handlers
    BOOL OnInitDialog ( HWND hwndFocus, LPARAM lParam );

    // Command handlers
    void OnUseCaptionText ( UINT uCode, int nID, HWND hwndCtrl );
    void OnUseFooterText ( UINT uCode, int nID, HWND hwndCtrl );
    void OnUseExpandedText ( UINT uCode, int nID, HWND hwndCtrl );
    void OnUseExpandoCollapsedText ( UINT uCode, int nID, HWND hwndCtrl );
    void OnUseExpandoExpandedText ( UINT uCode, int nID, HWND hwndCtrl );
    void OnUseCheckbox ( UINT uCode, int nID, HWND hwndCtrl );

    // Notification handlers
    void OnCaptionTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnMainTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnMainIconSelchange ( UINT uCode, int nID, HWND hwndCtrl );
    void OnContentTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnFooterTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnFooterIconSelchange ( UINT uCode, int nID, HWND hwndCtrl );
    void OnExpandedTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnExpandoExpandedTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnExpandoCollapsedTextChanged ( UINT uCode, int nID, HWND hwndCtrl );
    void OnCheckboxTextChanged ( UINT uCode, int nID, HWND hwndCtrl );

    // Data
    CWindow m_wndTD;
    CString m_sDefaultCaption;

    // Operations
    bool FillInTDConfig ( TASKDIALOGCONFIG& tdc );
    void OnTDNavigated();
    bool SaveToXML ( IXMLDOMDocumentPtr& pDoc, DWORD& dwFlags );

protected:
    // Data
    bool    m_bInInitDialog;

    // DDX vars
    CString m_sCaption, m_sMainInstruction, m_sContent, m_sFooter, m_sExpandedText, 
            m_sExpandoCollapsed, m_sExpandoExpanded, m_sCheckbox;
    bool m_bUseCaption, m_bUseFooter, m_bUseExpandedText, m_bUseExpandoCollapsedText,
         m_bUseExpandoExpandedText, m_bUseCheckbox;
    CComboBox m_wndMainIcon, m_wndFooterIcon;
};

#endif  // ndef TEXTTOOLSPAGE_H_INCLUDED

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) VMware
United States United States
Michael lives in sunny Mountain View, California. He started programming with an Apple //e in 4th grade, graduated from UCLA with a math degree in 1994, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.
Mike has been a a developer at Napster and at his own lil' startup, Zabersoft, a development company he co-founded with offices in Los Angeles and Odense, Denmark. Mike is now a senior engineer at VMware.

He also enjoys his hobbies of playing pinball, bike riding, photography, and Domion on Friday nights (current favorite combo: Village + double Pirate Ship). He would get his own snooker table too if they weren't so darn big! He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.

Mike was a VC MVP from 2005 to 2009.

Comments and Discussions