[Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?

PFJ paul at all-the-johnsons.co.uk
Wed Jun 21 06:53:27 EDT 2006


Hi,

> So do you think it could be a bug with resolving the base class? It 
> seems from the trace that it is going into a continuous loop, like it is 
> calling ContainsFocus on itself.

To be honest, all I saw was the segfault rather than the tonnes of
output. The baseclass seems to be working fine as well

I did the following to your code and if you run it, you'll see that the
baseclass is fine

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WinApp4
{
  public class Form1 : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.ComponentModel.Container components = null;

    public Form1()
    {
      InitializeComponent();
    }

    protected override void Dispose(bool disposing)
    {
      if (disposing)
      {
        if (components != null)
        {
          components.Dispose();
	}
      }
      base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
      this.button1 = new System.Windows.Forms.Button();
      this.button2 = new System.Windows.Forms.Button();
      this.SuspendLayout();

      this.button1.Location = new System.Drawing.Point(96, 32);
      this.button1.Name = "button1";
      this.button1.TabIndex = 0;
      this.button1.Text = "button1";
      this.button1.Click += new System.EventHandler(this.button1_Click);

      this.button2.Location = new System.Drawing.Point(96, 80);
      this.button2.Name = "button2";
      this.button2.TabIndex = 1;
      this.button2.Text = "button2";
      this.button2.Click += new System.EventHandler(this.button2_Click);

      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 262);
      this.Controls.Add(this.button2);
      this.Controls.Add(this.button1);
      this.Name = "Form1";
      this.Text = "Form1";
      this.ResumeLayout(false);
    }

    [STAThread]
    static void Main()
    {
      Application.Run(new Form1());
    }

    private void button1_Click(object sender, System.EventArgs e)
    {
      Console.Write(base.ContainsFocus);
    }

    private void button2_Click(object sender, System.EventArgs e)
    {
      Console.WriteLine(base.ContainsFocus);
    }
  }
}

The output (at least on my box) is

True (button 1 pressed - no return feed)
TrueTrue (button 2 pressed)

>From the looks of the original code, you've created the second button,
but never properly instantated it (it is declared as private swf.button
button2 at the start, but never created using this.button2 = new
swf.button()). That (to me) is the most likely candidate for the
breakage.

TTFN

Paul

-- 
"Logic, my dear Zoe, is merely the ability to be wrong with authority" -
Dr Who



More information about the Mono-winforms-list mailing list