Difference between revisions of "TTaskDialog"

From Lazarus wiki
Jump to navigationJump to search
m
m
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
{{TTaskDialog}}
 
{{TTaskDialog}}
  
'''TTaskDialog''' is a non-visual component, which shows full-featured dialogs at runtime, dialogs with rich features like Windows TaskDialog API has.
+
'''TTaskDialog''' [[image:ttaskdialogicon.png]] is a non-visual component, which shows full-featured dialogs at runtime, dialogs with rich features like Windows TaskDialog API has.
 
It is available on the [[Dialogs tab]] of the [[Component Palette]]. It is available since Lazarus 1.8.
 
It is available on the [[Dialogs tab]] of the [[Component Palette]]. It is available since Lazarus 1.8.
  
 
[[image:ttaskdialog.png]]  
 
[[image:ttaskdialog.png]]  
  
Dialog is shown with the Execute() method, and if it gets True, property ModalResult has id of pressed button:
+
Dialog is shown with the Execute() method, and if this returns [[True]], property ModalResult has ModalResult of the pressed button:
  
* id of standard button (OK, Cancel, Yes etc)
+
* ModalResult of standard button (mrOK, mrCancel, mrYes etc)
* id of custom button, which is specified in each button's ModalResult
+
* ModalResult of custom button, which was specified in each button's ModalResult
  
Also, property RadioButton has the radio-button object, which was clicked.
+
Execute returns <tt>True</tt> if the dialog was opened successfully. On Windows Vista and up, a native dialog is show, which may fail (because of inconsistent parameters), in which case an emulated taskdialog is shown. On all other platforms the emulated dialog is shown. So, in effect the result value of Execute will always be <tt>True</tt>.
 +
 
 +
Property MainIcon can be set to values for standard icons: none, warning, error, information, shield.
 +
 
 +
Property RadioButton has the radio-button object, which was clicked.
  
 
==Example==
 
==Example==
 +
 
This example shows how to create dialog in runtime, and to add custom buttons in runtime:
 
This example shows how to create dialog in runtime, and to add custom buttons in runtime:
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
   with TTaskDialog.Create(self) do
 
   with TTaskDialog.Create(self) do
 
     try
 
     try
Line 42: Line 47:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
[[image:TTaskDialog_confirm_removal.png]]
 +
 +
== See also ==
 +
 +
* [[Dialog Examples]]
 +
* [https://stackoverflow.com/questions/4979556/how-to-use-the-ttaskdialog Hint on stackoverflow.com]
 
{{LCL Components}}
 
{{LCL Components}}

Latest revision as of 23:32, 11 November 2023

English (en) suomi (fi) français (fr) русский (ru) 中文(中国大陆)‎ (zh_CN)

TTaskDialog ttaskdialogicon.png is a non-visual component, which shows full-featured dialogs at runtime, dialogs with rich features like Windows TaskDialog API has. It is available on the Dialogs tab of the Component Palette. It is available since Lazarus 1.8.

ttaskdialog.png

Dialog is shown with the Execute() method, and if this returns True, property ModalResult has ModalResult of the pressed button:

  • ModalResult of standard button (mrOK, mrCancel, mrYes etc)
  • ModalResult of custom button, which was specified in each button's ModalResult

Execute returns True if the dialog was opened successfully. On Windows Vista and up, a native dialog is show, which may fail (because of inconsistent parameters), in which case an emulated taskdialog is shown. On all other platforms the emulated dialog is shown. So, in effect the result value of Execute will always be True.

Property MainIcon can be set to values for standard icons: none, warning, error, information, shield.

Property RadioButton has the radio-button object, which was clicked.

Example

This example shows how to create dialog in runtime, and to add custom buttons in runtime:

  with TTaskDialog.Create(self) do
    try
      Title := 'Confirm removal';
      Caption := 'Confirm';
      Text := 'Remove selected item?';
      CommonButtons := [];
      with TTaskDialogButtonItem(Buttons.Add) do
      begin
        Caption := 'Remove';
        ModalResult := mrYes;
      end;
      with TTaskDialogButtonItem(Buttons.Add) do
      begin
        Caption := 'Keep';
        ModalResult := mrNo;
      end;
      MainIcon := tdiQuestion;
      if Execute then
        if ModalResult = mrYes then
          ShowMessage('Item removed');
    finally
      Free;
    end

TTaskDialog confirm removal.png

See also


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu