TheSwamp

Code Red => .NET => Topic started by: wannabe on April 15, 2009, 08:22:00 AM

Title: Displaying Forms in a Console Application (Inside Autocad)
Post by: wannabe on April 15, 2009, 08:22:00 AM
Another thread from me  :-). Hope you don't mind. I'm doing my best to fathom it out myself but some techniques are currently eluding me. Like this one.

In my console app. I created a form with all my controls on and wanted to test out that it appears when the command is loaded. Here is the code in my class:

Code: [Select]
           
{
    public class Class1
    {
        [CommandMethod("MultiB")]
        public void multiB()
        {
            Form1 form1 = new Form1();
            form1.Activate();
        }

       
    }
}

when debugging in CAD I get no errors, and nor do I get my form to display.

As always, just a nudge in the right direction would be appreciated, but anything additional will be happily absorbed.

Cheers.
Title: Re: Displaying Forms in a Console Application (Inside Autocad)
Post by: Glenn R on April 15, 2009, 08:28:08 AM
It seems to me, that you haven't displayed your dialog yet, therefor, you can't activate it.

If this is running inside AutoCAD, then I would use ShowModalDialog(), if not, then ShowDialog() as normal.
Title: Re: Displaying Forms in a Console Application (Inside Autocad)
Post by: wannabe on April 15, 2009, 08:30:58 AM
Ok. I read the Activate method as activating and providing focus to my form. I'll look into what you suggested.

Thanks :-)
Title: Re: Displaying Forms in a Console Application (Inside Autocad)
Post by: Glenn R on April 15, 2009, 08:32:40 AM
That's correct - but you have to show it first :D
Title: Re: Displaying Forms in a Console Application (Inside Autocad)
Post by: wannabe on April 15, 2009, 08:35:24 AM
You = smart. Me = fool.  :oops:

Disappointed I missed that one; but grateful for your help.

Cheers again. :-)