Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-10-29
4
Medium Priority
?
682 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 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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 …
Introduction to Processes

604 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