Add wxRichMessageDialog class.
This is a generalization of wxMessageDialog based on the native task dialog under recent (Vista and later) Windows versions and implemented generically for the other ports for now. It provides the possibility to use additional controls in the message boxes (checkbox useful for the "Don't ask me again" kind of dialogs and collapsible detailed explanations field) and better look and feel under Windows. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
79
src/msw/richmsgdlg.cpp
Normal file
79
src/msw/richmsgdlg.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/msw/richmsgdlg.cpp
|
||||
// Purpose: wxRichMessageDialog
|
||||
// Author: Rickard Westerlund
|
||||
// Created: 2010-07-04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2010 wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_RICHMSGDLG
|
||||
|
||||
#include "wx/richmsgdlg.h"
|
||||
|
||||
// This will define wxHAS_MSW_TASKDIALOG if we have support for it in the
|
||||
// headers we use.
|
||||
#include "wx/msw/private/msgdlg.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRichMessageDialog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxRichMessageDialog::ShowModal()
|
||||
{
|
||||
#ifdef wxHAS_MSW_TASKDIALOG
|
||||
using namespace wxMSWMessageDialog;
|
||||
|
||||
if ( HasNativeTaskDialog() )
|
||||
{
|
||||
// create a task dialog
|
||||
WinStruct<TASKDIALOGCONFIG> tdc;
|
||||
wxMSWTaskDialogConfig wxTdc(*this);
|
||||
|
||||
wxTdc.MSWCommonTaskDialogInit( tdc );
|
||||
|
||||
// add a checkbox
|
||||
if ( !m_checkBoxText.empty() )
|
||||
{
|
||||
tdc.pszVerificationText = m_checkBoxText.wx_str();
|
||||
if ( m_checkBoxValue )
|
||||
tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;
|
||||
}
|
||||
|
||||
// add collapsible footer
|
||||
if ( !m_detailedText.empty() )
|
||||
tdc.pszExpandedInformation = m_detailedText.wx_str();
|
||||
|
||||
TaskDialogIndirect_t taskDialogIndirect = GetTaskDialogIndirectFunc();
|
||||
if ( !taskDialogIndirect )
|
||||
return wxID_CANCEL;
|
||||
|
||||
// create the task dialog, process the answer and return it.
|
||||
BOOL checkBoxChecked;
|
||||
int msAns;
|
||||
HRESULT hr = taskDialogIndirect( &tdc, &msAns, NULL, &checkBoxChecked );
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wxLogApiError( "TaskDialogIndirect", hr );
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
m_checkBoxValue = checkBoxChecked != FALSE;
|
||||
|
||||
return MSWTranslateReturnCode( msAns );
|
||||
}
|
||||
#endif // wxHAS_MSW_TASKDIALOG
|
||||
|
||||
// use the generic version when task dialog is't available at either
|
||||
// compile or run-time.
|
||||
return wxGenericRichMessageDialog::ShowModal();
|
||||
}
|
||||
|
||||
#endif // wxUSE_RICHMSGDLG
|
||||
Reference in New Issue
Block a user