TheSwamp

Code Red => .NET => Topic started by: cadplayer on October 05, 2015, 02:32:38 AM

Title: Hide() winform, when pressing escape (error-message)
Post by: cadplayer 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 ?
Title: Re: Hide() winform, when pressing escape (error-message)
Post by: cadplayer on October 05, 2015, 07:28:47 AM
(https://dl.dropboxusercontent.com/u/174474939/PICTURE/error.png)
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");
            }
Title: Re: Hide() winform, when pressing escape (error-message)
Post by: MexicanCustard on October 05, 2015, 10:21:53 AM
Where are you assigning SurfaceId if the promptresult is anything other than Ok?
Title: Re: Hide() winform, when pressing escape (error-message)
Post by: cadplayer on October 22, 2015, 02:12:27 PM
Yes thatīs clear - thank you!