Layout by code - a wonderfull tool but....

  • From: "Bue Vester-Andersen" <bva_lists@xxxxxxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 2 Aug 2011 21:09:21 +0200

Hi,

First of all a million thanks to Jamal for his great work. LBC is just about
the most fantastic programming tool I have ever stumbled upon. I am
congenitally blind and have always found it next to imposible to work out a
layout that would work at all.

Now for my problem: 
I am trying to make a template for use with Visual Studio 2008 building on
the template for a Windows forms application. Everything compiles fine, but
when I run the resulting program I get the following exception (translated
from Danish):

Invalid cast exception
{"an object of the type
'Microsoft.VisualStudio.HostingProcess.ParkingWindow' can not  be converted
to the type 'Homer.LbcForm'."}

The exception occurs at the CompleteWindow() call. It looks to me as if I
was referencing the form before it is actually created. The funny thing is
that everything works fine when I step into the code using f10 and f11. I
don't suppose there could be a race condition? Hope someone can help me.

Below is the code I am using. As I said, it is built on the Windows form
application template. I thought that the use of component initialization
might be the cause of my trouble, so I tried to remove all the designer and
component stuff, but it didn't solve anything.

LbcForm1.cs

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;
using Homer;

namespace LBCFormsApplication1
{
        public partial class LbcForm1 : LbcForm
        {
                public LbcForm1()

        
                {
                        InitializeComponent();
                        this.Init("LbcForm1", null, null);
                        this.AddMyControlls();
                        
                }

                Private void AddMyControlls()
                {
                        // Add controlls here.
//                      AddButton("ok");

                }

                public void OnEvent(string sEvent, Control oSender,
EventArgs oArgs)
                {
                        // Add event code here.

                }

        }
}

LbcForm1.Designer.cs

namespace LBCFormsApplication1
{
        partial class LbcForm1
        {
                /// <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.components = new
System.ComponentModel.Container();
                        this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
                        }

                #endregion
        }
}


Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace LBCFormsApplication1
{
        static class Program
        {
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
                [STAThread]
                static void Main()
                {
                        Application.EnableVisualStyles();
        
Application.SetCompatibleTextRenderingDefault(false);
                        LbcForm1 oLbcForm = new LbcForm1();

                        // Add further initialization here.

                        // Uncomment to run as window.
                                oLbcForm.CompleteWindow();

                        // Uncomment to run as dialog.
//                       oLbcForm.CompleteDialog();

                }

        }
}


Best regards
Bue

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts:

  • » Layout by code - a wonderfull tool but.... - Bue Vester-Andersen