]> git.saurik.com Git - wxWidgets.git/blame - src/msw/richmsgdlg.cpp
wxMSW: return correct value from wxMessageDialog::GetReturnCode().
[wxWidgets.git] / src / msw / richmsgdlg.cpp
CommitLineData
a1bdd4ab
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/richmsgdlg.cpp
3// Purpose: wxRichMessageDialog
4// Author: Rickard Westerlund
5// Created: 2010-07-04
a1bdd4ab
VZ
6// Copyright: (c) 2010 wxWidgets team
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14#pragma hdrstop
15#endif
16
17#if wxUSE_RICHMSGDLG
18
19#include "wx/richmsgdlg.h"
691745ab 20#include "wx/modalhook.h"
a1bdd4ab 21
d2bc8725
PC
22#ifndef WX_PRECOMP
23 #include "wx/msw/private.h"
24#endif
25
a1bdd4ab
VZ
26// This will define wxHAS_MSW_TASKDIALOG if we have support for it in the
27// headers we use.
28#include "wx/msw/private/msgdlg.h"
29
30// ----------------------------------------------------------------------------
31// wxRichMessageDialog
32// ----------------------------------------------------------------------------
33
34int wxRichMessageDialog::ShowModal()
35{
691745ab 36 WX_HOOK_MODAL_DIALOG();
643e9cf9 37
a1bdd4ab
VZ
38#ifdef wxHAS_MSW_TASKDIALOG
39 using namespace wxMSWMessageDialog;
40
41 if ( HasNativeTaskDialog() )
42 {
43 // create a task dialog
44 WinStruct<TASKDIALOGCONFIG> tdc;
45 wxMSWTaskDialogConfig wxTdc(*this);
46
47 wxTdc.MSWCommonTaskDialogInit( tdc );
48
49 // add a checkbox
50 if ( !m_checkBoxText.empty() )
51 {
017dc06b 52 tdc.pszVerificationText = m_checkBoxText.t_str();
a1bdd4ab
VZ
53 if ( m_checkBoxValue )
54 tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;
55 }
56
57 // add collapsible footer
58 if ( !m_detailedText.empty() )
017dc06b 59 tdc.pszExpandedInformation = m_detailedText.t_str();
a1bdd4ab
VZ
60
61 TaskDialogIndirect_t taskDialogIndirect = GetTaskDialogIndirectFunc();
62 if ( !taskDialogIndirect )
63 return wxID_CANCEL;
64
65 // create the task dialog, process the answer and return it.
66 BOOL checkBoxChecked;
67 int msAns;
68 HRESULT hr = taskDialogIndirect( &tdc, &msAns, NULL, &checkBoxChecked );
69 if ( FAILED(hr) )
70 {
71 wxLogApiError( "TaskDialogIndirect", hr );
72 return wxID_CANCEL;
73 }
74 m_checkBoxValue = checkBoxChecked != FALSE;
75
76 return MSWTranslateReturnCode( msAns );
77 }
78#endif // wxHAS_MSW_TASKDIALOG
79
80 // use the generic version when task dialog is't available at either
81 // compile or run-time.
82 return wxGenericRichMessageDialog::ShowModal();
83}
84
85#endif // wxUSE_RICHMSGDLG