Solved

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

Posted on 2006-10-29
4
652 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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