Author Topic: Hide() winform, when pressing escape (error-message)  (Read 1412 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Hide() winform, when pressing escape (error-message)
« on: October 05, 2015, 02:32:38 AM »
Hello!
I would like catch an Escape-event in case I press a button "Select", the winform hides and I can select someone. But if I donīt select as I press escape-key I get a error-message.
I try it to catch the Formclosing-event, it works, but first I get Autocad-error-message and than it comes formclosing-message. Have somebody a trick to solve it better ?

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Hide() winform, when pressing escape (error-message)
« Reply #1 on: October 05, 2015, 07:28:47 AM »

I get this message if I press "Escape" in the method

Code: [Select]
try
            {
                PromptEntityOptions options = new PromptEntityOptions("\nSelect a Surface: ");
                options.AllowNone = false;
                options.SetRejectMessage("\nThe selected object is not a Surface.");
                options.AddAllowedClass(typeof(CivSurface), false);
               
                PromptEntityResult result = ed.GetEntity(options);
                if (result.Status == PromptStatus.OK)
                {
                    this.SurfaceId = result.ObjectId;
                }

                if (ObjectId.Null == SurfaceId)
                {
                    ed.WriteMessage("\nNo TIN Surface object was selected.");
                }
            }
            catch(Exception ex)
            {
                ed.WriteMessage("\nClose Program");
            }

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Hide() winform, when pressing escape (error-message)
« Reply #2 on: October 05, 2015, 10:21:53 AM »
Where are you assigning SurfaceId if the promptresult is anything other than Ok?
Revit 2019, AMEP 2019 64bit Win 10

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Hide() winform, when pressing escape (error-message)
« Reply #3 on: October 22, 2015, 02:12:27 PM »
Yes thatīs clear - thank you!