Solved

Defining a form as "modal" or "modeless" in C#

Posted on 2006-10-29
4
650 Views
Last Modified: 2008-01-16
This show method will display a modal form if placed in an event handler...

Form f = new Form();
f.Show(this);

... but how does a C# app written in Visual Studio indicate the default form is displayed as modal or modeless?

namespace AWEViewer
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(641, 379);
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "AWE Viewer Main Form";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion
    }
}

Thanks for any help.

sundownr
0
Comment
Question by:sundownr
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17829574
0
 

Author Comment

by:sundownr
ID: 17829633
Perhaps I am missing something as I did see this link before asking my question...

I have no problem establishing a "modal" or "modeless" form with event code... what I do not understand is how Visual Studio sets "modal" or "modeless" on a deault form window? The documentation does not seem to cover this
point. Is there a method which sets this property?

sundownr
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17829673
Internally modal form is implemented by the following way: all ather application forms are disabled when ShowDialog is called, and enables them when ShowDialog exits. This allows to all other form to redraw themself and to handle different events (like Timer Tick event), but they cannot be activated.
Form itself doesn't know whether it is modal or not.
0
 

Author Comment

by:sundownr
ID: 17829773
It appears I have confused dialogs with forms.

To have "moduality" requires dialogs... not forms.

I think I need to rewire my brain.

Thanks... and have a great day.

sundownr
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now