Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aborting a form (in vfp return .f. in .INIT)
Message
From
17/01/2012 14:26:16
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 8.0
OS:
Windows 7
Network:
Windows NT
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01533071
Message ID:
01533129
Views:
50
Hi,
Yes, better to avoid having the .Show() execute in the calling routine if poss. - so ideally Pete's suggestion is best. I was just trying to comply with Marc's stipulation that the decision on whether to fully instantiate should be contained within the window itself.

I must admit I don't know what goes on when .Show() is executed but .Close() precedes it - I just tried it and it appeared to give the required result :-}

>I don't know nearly as much about it as you guys do but it seems like invoking .Show has to be part of the problem. Isn't there some way to thwart before calling it?
>
>Hmmm, that comment about "real test" in frm.CanShowForm() is interesting. Maybe that's the thwart point?
>
>
>>I was going to suggest something similar but then Marc said he wanted to encapsulate the behaviour in the form itself...
>>
>>>Hi Marc, what about something like this ? ( I
>>>
>>>
>>>using System;
>>>using System.Collections.Generic;
>>>using System.ComponentModel;
>>>using System.Data;
>>>using System.Drawing;
>>>using System.Linq;
>>>using System.Text;
>>>using System.Windows.Forms;
>>>
>>>namespace Test
>>>{
>>>    public class Form1 : Form
>>>    {
>>>        public Form1()
>>>        {
>>>            InitializeComponent();
>>>        }
>>>
>>>    private void InitializeComponent()
>>>        {
>>>            this.button1 = new System.Windows.Forms.Button();
>>>            this.SuspendLayout();
>>>            // 
>>>            // button1
>>>            // 
>>>            this.button1.Location = new System.Drawing.Point(89, 146);
>>>            this.button1.Name = "button1";
>>>            this.button1.Size = new System.Drawing.Size(115, 23);
>>>            this.button1.TabIndex = 0;
>>>            this.button1.Text = "Create New Form";
>>>            this.button1.UseVisualStyleBackColor = true;
>>>            this.button1.Click += new System.EventHandler(this.button1_Click);
>>>            // 
>>>            // Form1
>>>            // 
>>>            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
>>>            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
>>>            this.ClientSize = new System.Drawing.Size(292, 273);
>>>            this.Controls.Add(this.button1);
>>>            this.Name = "Form1";
>>>            this.Text = "Form1";
>>>            this.ResumeLayout(false);
>>>
>>>        }
>>>
>>>        #endregion
>>>
>>>        private System.Windows.Forms.Button button1;
>>>
>>>        private void button1_Click(object sender, EventArgs e)
>>>        {
>>>            MyForm frm = new MyForm();
>>>            
>>>            if (frm.CanShowForm())
>>>                frm.Show();
>>>            else
>>>                frm.Close();
>>>
>>>        }
>>>    }
>>>
>>>    public class MyForm : Form
>>>    {
>>>        public bool CanShowForm()
>>>        {
>>>            if (0 == 1) // obviously replace this with real test 
>>>                return true;
>>>            
>>>
>>>
>>>                return false;
>>>
>>>        }
>>>    }
>>>}
>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform