Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sql how to exclude from a table 3 73
countX 22 70
changeXy challenge 13 58
countPairs challenge 7 58
A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

760 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

22 Experts available now in Live!

Get 1:1 Help Now