[Mono-bugs] [Bug 82531][Nor] New - CommonDialog only useful for Mono internal implementations

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Aug 22 12:28:21 EDT 2007

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by andyhume32 at yahoo.co.uk.


--- shadow/82531	2007-08-22 12:28:21.000000000 -0400
+++ shadow/82531.tmp.19831	2007-08-22 12:28:21.000000000 -0400
@@ -0,0 +1,78 @@
+Bug#: 82531
+Product: Mono: Class Libraries
+Version: 1.2
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: andyhume32 at yahoo.co.uk               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: CommonDialog only useful for Mono internal implementations
+In summary after the Form from the sub-class implementation has been 
+displayed the Mono CommonDialog implementation displays an internally-
+defined Form.  The user has to manually close this blank form, and the 
+result returned to the calling code is thus never DialogResult.OK.
+The documentation for people implementing the abstract class 
+System.Windows.Forms.CommonDialog is admittedly very sparse, but one 
+overrides the RunDialog abstract method is to display the dialog.  Thus 
+the following is a valid implementation on the MSFT platform:
+class MyOpenCommonDialog : CommonDialog
+   protected override bool RunDialog(IntPtr hwndOwner)
+   {
+      DialogResult rslt = MessageBox.Show(
+         "My text. Select item?", "My caption",
+         MessageBoxButtons.OKCancel);
+      return rslt == DialogResult.OK;   
+   }
+On calling ShowDialog, the MessageBox is seen, and the call returns OK or 
+On Mono however there is an internal form instance displayed after the 
+RunDialog method has completed successfully.  When using the above 
+implementation on the Mono platform, one sees the MessageBox and then the 
+empty form!  The user must close it with the [X] box, and thus the result 
+of ShowDialog is then Cancel.  (If the user cancelled the 'real' dialog, 
+then the extra form isn't displayed, and a result of None is received).
+The code is:
+   internal class DialogForm : Form { ... ... }
+   internal DialogForm   form;
+   public DialogResult ShowDialog(IWin32Window ownerWin32) {
+      // Prep the dialog
+      if (RunDialog(form.Handle)) {
+         // Run
+         form.ShowDialog(ownerWin32);
+      }
+      return form.DialogResult;
+   }
+Thus this implementation is only of use by internal Mono classes.  
+Firstly the developer to use their own window, and secondly there's no 
+way for third-party code to access the internal form instance.
+I suppose that the class needs to be split into two: one for general use 
+and supporting the existing Mono sub-classed.  All the DialogForm 
+infrastructure should be moved to a sub class (CommonMonoDialog?).  
+ShowDialog should only be present in the base class, and should simply 
+call RunDialog converting the bool to DialogResult.OK/Cancel respectively.
+RunDialog should be abstract in CommonDialog, and in the CommonMonoDialog 
+class using the current code from ShowDialog, and with the abstract 
+method implemented by the internal Mono classes being renamed to 
+SetUpDialog.  The current six descendents (ColorDialog, FileDialog, etc) 
+will need to be updated respectively.

More information about the mono-bugs mailing list