Solved

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

Posted on 2006-10-29
4
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
Introduction to Processes

689 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