// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2004-2006 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Peter Bartok (pbartok@novell.com)
#region DialogForm Constructors
internal DialogForm(CommonDialog owner) {
this.owner = owner;
+ ControlBox = true;
+ MinimizeBox = false;
+ MaximizeBox = false;
+ ShowInTaskbar = false;
+ FormBorderStyle = FormBorderStyle.Sizable;
+ StartPosition = FormStartPosition.CenterScreen;
}
#endregion DialogForm Constructors
get {
CreateParams cp;
- ControlBox = true;
- MinimizeBox = false;
- MaximizeBox = false;
-
cp = base.CreateParams;
- cp.Style = (int)(WindowStyles.WS_POPUP | WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS);
+ cp.Style |= (int)(WindowStyles.WS_POPUP | WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU);
return cp;
}
#region Internal Methods
internal DialogResult RunDialog () {
- this.StartPosition = FormStartPosition.CenterScreen;
-
owner.InitFormsSize (this);
this.ShowDialog ();
#region Local Variables
internal DialogForm form;
+ private object tag;
#endregion Local Variables
#region Public Constructors
public CommonDialog() {
- form = new DialogForm(this);
}
#endregion Public Constructors
+ #region Public Properties
+ [Localizable (false)]
+ [Bindable (true)]
+ [TypeConverter (typeof (StringConverter))]
+ [DefaultValue (null)]
+ [MWFCategory ("Data")]
+ public object Tag {
+ get { return this.tag; }
+ set { this.tag = value; }
+ }
+ #endregion
+
#region Internal Methods
internal virtual void InitFormsSize(Form form) {
// Override this to set a default size for the form
#endregion Internal Methods
#region Public Instance Methods
- public abstract void Reset();
+ public abstract void Reset ();
public DialogResult ShowDialog() {
- return ShowDialog(null);
+ return ShowDialog (null);
}
- public DialogResult ShowDialog(IWin32Window ownerWin32) {
- #if broken
- Control owner = null;
-
- if (ownerWin32 != null) {
- owner = Control.FromHandle(ownerWin32.Handle);
- }
- #endif
-
- RunDialog(form.Handle);
-
- if (form.Visible) {
- throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
- }
-
- if (!form.IsHandleCreated) {
- form.CreateControl();
+ public DialogResult ShowDialog (IWin32Window owner)
+ {
+ // This is an external derived CommonDialog
+ if (form == null) {
+ if (RunDialog (owner == null ? IntPtr.Zero : owner.Handle))
+ return DialogResult.OK;
+ return DialogResult.Cancel;
}
-
- #if broken
- form.form_parent_window.Parent = owner;
- #endif
-
- XplatUI.SetModal(form.window.Handle, true);
-
- form.Show();
-
- form.end_modal = false;
- form.is_modal = true;
- Application.ModalRun(form);
- form.is_modal = false;
- form.Hide();
-
- XplatUI.SetModal(form.window.Handle, false);
+
+ // This is an internal derived CommonDialog
+ if (RunDialog (form.Handle))
+ form.ShowDialog (owner);
return form.DialogResult;
}
}
protected virtual void OnHelpRequest(EventArgs e) {
- if (HelpRequest != null) {
- HelpRequest(this, e);
- }
+ EventHandler eh = (EventHandler)(Events [HelpRequestEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual IntPtr OwnerWndProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
#endregion // Protected Instance Methods
#region Events
- public event EventHandler HelpRequest;
+ static object HelpRequestEvent = new object ();
+
+ public event EventHandler HelpRequest {
+ add { Events.AddHandler (HelpRequestEvent, value); }
+ remove { Events.RemoveHandler (HelpRequestEvent, value); }
+ }
#endregion // Events
}
}