View Issue Details

IDProjectCategoryView StatusLast Update
0036069LazarusLCLpublic2019-09-29 12:45
ReporterBart BroersmaAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindowsOS Version10
Product Version2.1 (SVN)Product Buildr61683 
Target Version2.0.6Fixed in Version2.0.6 
Summary0036069: TTaskDialog wrong ModalResult when pressing Close button (CommonButtons)
DescriptionReported by Alexander Hoffmann on ML.

If you place a TTaskDialog on a form and have tcbClose in CommonButtons, then pressing on this Close button sets ModalResult to mrAll (Windows ITaskDialogIndirect) or mrAbort (simulated TTaskDialog).
Steps To ReproduceBuild attached task.zip project (never mind all the unused units, it's a simple botched up test program).
Run, click button1, click Close button of dialog.
Additional InformationClicking close button (native ITaskDialigIndirect) sets IDButton correctly to 8, but you cannot directly map buttonID to ModalResult like that, since mrClose = 11.
On simulated dialog
TCommonButton = (
    cbOK, cbYes, cbNo, cbCancel, cbRetry, cbClose) maps to
TD_BTNMOD: array[TCommonButton] of Integer = (
    mrOk, mrYes, mrNo, mrCancel, mrRetry, mrAbort);

Possible patch attached.
TagsNo tags attached.
Fixed in Revisionr61947
LazTarget2.0.6
Widgetset
Attached Files
  • task.zip (3,999 bytes)
  • taskdialog.mrclose.diff (1,207 bytes)
    Index: lcl/include/taskdialog.inc
    ===================================================================
    --- lcl/include/taskdialog.inc	(revision 61683)
    +++ lcl/include/taskdialog.inc	(working copy)
    @@ -99,7 +99,19 @@
       ): TModalResult;
     begin
       if AButtonID<100 then
    -    Result := AButtonID
    +    begin
    +      case AButtonID of
    +        IDOK: Result := mrOK;
    +        IDCANCEL: Result := mrCancel;
    +        IDABORT: Result := mrAbort;
    +        IDRETRY: Result := mrRetry;
    +        IDIGNORE: Result := mrIgnore;
    +        IDYES: Result := mrYes;
    +        IDNO: Result := mrNo;
    +        IDCLOSE: Result := mrClose;
    +        else Result := AButtonID
    +      end;
    +    end
       else if (AButtonID-100<Buttons.Count) then
         Result := Buttons[AButtonID-100].ModalResult
       else
    Index: lcl/lcltaskdialog.pas
    ===================================================================
    --- lcl/lcltaskdialog.pas	(revision 61683)
    +++ lcl/lcltaskdialog.pas	(working copy)
    @@ -446,7 +446,7 @@
     
     const
       TD_BTNMOD: array[TCommonButton] of Integer = (
    -    mrOk, mrYes, mrNo, mrCancel, mrRetry, mrAbort);
    +    mrOk, mrYes, mrNo, mrCancel, mrRetry, mrClose);
     
     function TD_BTNS(button: TCommonButton): pointer;
     begin
    
    taskdialog.mrclose.diff (1,207 bytes)

Activities

Bart Broersma

2019-09-12 18:34

developer  

task.zip (3,999 bytes)
taskdialog.mrclose.diff (1,207 bytes)
Index: lcl/include/taskdialog.inc
===================================================================
--- lcl/include/taskdialog.inc	(revision 61683)
+++ lcl/include/taskdialog.inc	(working copy)
@@ -99,7 +99,19 @@
   ): TModalResult;
 begin
   if AButtonID<100 then
-    Result := AButtonID
+    begin
+      case AButtonID of
+        IDOK: Result := mrOK;
+        IDCANCEL: Result := mrCancel;
+        IDABORT: Result := mrAbort;
+        IDRETRY: Result := mrRetry;
+        IDIGNORE: Result := mrIgnore;
+        IDYES: Result := mrYes;
+        IDNO: Result := mrNo;
+        IDCLOSE: Result := mrClose;
+        else Result := AButtonID
+      end;
+    end
   else if (AButtonID-100<Buttons.Count) then
     Result := Buttons[AButtonID-100].ModalResult
   else
Index: lcl/lcltaskdialog.pas
===================================================================
--- lcl/lcltaskdialog.pas	(revision 61683)
+++ lcl/lcltaskdialog.pas	(working copy)
@@ -446,7 +446,7 @@
 
 const
   TD_BTNMOD: array[TCommonButton] of Integer = (
-    mrOk, mrYes, mrNo, mrCancel, mrRetry, mrAbort);
+    mrOk, mrYes, mrNo, mrCancel, mrRetry, mrClose);
 
 function TD_BTNS(button: TCommonButton): pointer;
 begin
taskdialog.mrclose.diff (1,207 bytes)

Bart Broersma

2019-09-12 18:37

developer   ~0118052

Since I know next to nothing about TTaskDialog I did not commit my patch.
Zeljko or Juha perhaps?

Bart Broersma

2019-09-29 12:44

developer   ~0118184

Please test and close if OK.

Issue History

Date Modified Username Field Change
2019-09-12 18:34 Bart Broersma New Issue
2019-09-12 18:34 Bart Broersma File Added: task.zip
2019-09-12 18:34 Bart Broersma File Added: taskdialog.mrclose.diff
2019-09-12 18:37 Bart Broersma Note Added: 0118052
2019-09-12 18:38 Bart Broersma Reproducibility have not tried => always
2019-09-12 18:38 Bart Broersma Target Version => 2.0.6
2019-09-12 18:38 Bart Broersma LazTarget => 2.0.6
2019-09-29 12:44 Bart Broersma Assigned To => Bart Broersma
2019-09-29 12:44 Bart Broersma Status new => resolved
2019-09-29 12:44 Bart Broersma Resolution open => fixed
2019-09-29 12:44 Bart Broersma Fixed in Version => 2.0.6
2019-09-29 12:44 Bart Broersma Fixed in Revision => r61947
2019-09-29 12:44 Bart Broersma Note Added: 0118184
2019-09-29 12:45 Bart Broersma Status resolved => closed