.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hiding a Form causes entire ACAD application to lose focus (AutoCAD 2006)

24 REPLIES 24
Reply
Message 1 of 25
Anonymous
1796 Views, 24 Replies

Hiding a Form causes entire ACAD application to lose focus (AutoCAD 2006)


I've noticed strange behaviour when hiding a
modal Form:

 

Dim Form
color=#0000ff size=2>As

size=2>New
MyForm

Application.ShowModalDialog(Form)

Form.Hide

''' Do something...

Form Show

 

When Form.Hide gets executed AutoCAD's
main window completely looses it's

face=Verdana> focus, causing ugly flickering (if only). Is there any smart
workaround to force AutoCAD not to lose focus when Form.Hide gets
executed?

 

Regards,

Maksim Sestic

 

 

 

 
24 REPLIES 24
Message 2 of 25
jimmie_fulton
in reply to: Anonymous

Does this work better for you?

Form.Visible = False
' Do Something
Form.Visible = True
Message 3 of 25
Anonymous
in reply to: Anonymous


No, it didn't
help. Annoying flickering (ACAD looses focus and then regains it) still
happening. It seems to me that
size=2>Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog

implementation, which is (I believe) based on AutoCAD's Application Form,
passes certain events to it's parent without some handy
overriding.

 

How about a third constructor of
ShowModaDialog:


Public Shared Function
ShowModalDialog

(ByVal
owner As

size=1>System.Windows.Forms.IWin32Window
,
ByVal
formToShow As

face="Courier New">System.Windows.Forms.Form

face="Courier New">,
ByVal
persistSizeAndPosition As

size=1>Boolean

face="Courier New">) As
color=#008000
size=1>System.Windows.Forms.DialogResult


When should I
use it?  

 

Regards,

Maksim Sestic

 

Does this work better for
you?

Form.Visible = False
' Do Something
Form.Visible =
True
Message 4 of 25
cgay
in reply to: Anonymous

Maksim,

First off, what versions of AutoCAD & Visual Studio are you using.

Second, how are you initially hiding the form after you ShowModalDialog? Are you calling the hide method from within the form? Is it immediately after the form is shown?

Third, maybe you could reconsider the variable name "Form" you are using. Form is a type and it is probably not good practice to use it. Although it's not restricted, I can conceive several situations where this is going to cause headaches.
Message 5 of 25
Anonymous
in reply to: Anonymous


1) AutoCAD
2006 / VS.NET 2003

 

2) I'm calling the .Hide method from control
class which initializes MyForm in first place. There are point-picking loops in
my code that require form to be invisible/hidden. It doesn't get hidden
immediately after Form.Show gets executed, it just gets hidden when user
clicks on a form's button.

 

3) Well, that was just an example
:-)

 

To conclude - there's someting tricky about
AutoCAD's ModalDialog implementation...

 

Regards,

Maksim Sestic

 

 

 

 

 

Maksim,

First off, what
versions of AutoCAD & Visual Studio are you using.

Second, how are
you initially hiding the form after you ShowModalDialog? Are you calling the
hide method from within the form? Is it immediately after the form is
shown?

Third, maybe you could reconsider the variable name "Form" you are
using. Form is a type and it is probably not good practice to use it. Although
it's not restricted, I can conceive several situations where this is going to
cause headaches.
Message 6 of 25
Anonymous
in reply to: Anonymous

Is the code that calls ShowModalDialog() executed from
a registered command handler, or something else?

Your problem is most likely that your form is being shown
by code that's running in the wrong execution context.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:5063409@discussion.autodesk.com...
No, it didn't help. Annoying flickering (ACAD looses focus and then regains it) still happening. It seems to me that Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog implementation, which is (I believe) based on AutoCAD's Application Form, passes certain events to it's parent without some handy overriding.

How about a third constructor of ShowModaDialog:
Public Shared Function ShowModalDialog(ByVal owner As System.Windows.Forms.IWin32Window, ByVal formToShow As System.Windows.Forms.Form, ByVal persistSizeAndPosition As Boolean) As System.Windows.Forms.DialogResult

When should I use it?

Regards,
Maksim Sestic

wrote in message news:5063304@discussion.autodesk.com...
Does this work better for you?

Form.Visible = False
' Do Something
Form.Visible = True
Message 7 of 25
cgay
in reply to: Anonymous

Maksim,

I have created a simple project that may help you.

If you are prompting the user, you don't need to hide a form.
AutoCAD will hide it when you call the editor.get??? methods.

Let me know if it works or not.

C
Message 8 of 25
HenryHe
in reply to: Anonymous

You can use this dll(attach file).
For example:
//"this" is the class derived from "Form".
using(ARX.HideFormTool tool=new ARX.HideFormTool(this))
{
if(!this.DoIt())
tool.ShowWhenDispose=false;
}
Message 9 of 25
Anonymous
in reply to: Anonymous

>> If you are prompting the user, you don't need to hide a form.
>> AutoCAD will hide it when you call the editor.get??? methods.

Yes it will, but if the form is already hidden, then
the GetXxxx method should do nothing.

It needs to work that way because there's cases
where I may want to prompt for several values
while the form remains hidden, so repeatedly
showing/hiding it between each successive input
request isn't going to work well in that case
(for example, the Hatch dialog's "Add Pick points"
button works like that).

A simple test (C#, with nothing but a form with
a single button and label on it) seems to confirm
that the form can be hidden and shown manually,
without relying on the call to GetPoint() to do it
for you:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace ExtensionApplication1
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

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

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(150, 66);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(157, 25);
this.button1.TabIndex = 0;
this.button1.Text = "Pick points";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(162, 119);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 16);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(450, 182);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion


[CommandMethod("GetPointTest")]
public static void GetPointTest()
{
using( Form1 form = new Form1() )
AcadApp.ShowModalDialog(form);
}

private void button1_Click(object sender, System.EventArgs e)
{
Editor editor = AcadApp.DocumentManager.MdiActiveDocument.Editor;
ArrayList list = new ArrayList();
PromptPointOptions opts = new PromptPointOptions();
opts.Message = "\nNext point (or ENTER when done): ";
opts.AllowNone = true;
this.Visible = false;
try
{
while( true )
{
PromptPointResult res = editor.GetPoint(opts);
if( res.Status != PromptStatus.OK )
break;

list.Add(res.Value);
}
}
finally
{
this.Visible = true;
label1.Text = string.Format("{0} points picked", list.Count);
}
}
}
}


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5064254@discussion.autodesk.com...
Maksim,

I have created a simple project that may help you.

If you are prompting the user, you don't need to hide a form.
AutoCAD will hide it when you call the editor.get??? methods.

Let me know if it works or not.

C
Message 10 of 25
Anonymous
in reply to: Anonymous


Tony's right, I need to pick several points (as
explained in my previous post) and don't want to rely on AutoCAD showing/hiding
my ModalDialog consequently. Try to reproduce that odd behaviour
via:

 

1) Open few Explorer windows and let them remain
open

2) Run AutoCAD and NETLOAD Tony's library
(ACAD keeps focus)

3) Run GetPointTest command (now Form1 gets
displayed and keeps focus)

4) Click the button to start points
acquisition - what happens then?

 

4.1) Form1 gets hidden

4.2) ACAD's main window looses it's focus
for a second, enough time to see opened windows in step 1)

4.3) ACAD's main window regains focus and lets
you pick points...

 

Pretty odd behaviour.

 

Regards,

Maksim Sestic

 

 

 

 

 

>> If you
are prompting the user, you don't need to hide a form.
>> AutoCAD will
hide it when you call the editor.get??? methods.

Yes it will, but if the
form is already hidden, then
the GetXxxx method should do nothing. 


It needs to work that way because there's cases
where I may want to
prompt for several values
while the form remains hidden, so repeatedly

showing/hiding it between each successive input
request isn't going to
work well in that case
(for example, the Hatch dialog's "Add Pick points"

button works like that).

A simple test (C#, with nothing but a form
with
a single button and label on it) seems to confirm
that the form can
be hidden and shown manually,
without relying on the call to GetPoint() to do
it
for you:

using System;
using System.Drawing;
using
System.Collections;
using System.ComponentModel;
using
System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using
Autodesk.AutoCAD.ApplicationServices;
using
Autodesk.AutoCAD.EditorInput;
using AcadApp =
Autodesk.AutoCAD.ApplicationServices.Application;

namespace
ExtensionApplication1
{
   /// <summary>
  
/// Summary description for Form1.
   ///
</summary>
   public class Form1 :
System.Windows.Forms.Form
   {
     
private System.Windows.Forms.Button button1;
     
private System.Windows.Forms.Label label1;
      ///
<summary>
      /// Required designer
variable.
      ///
</summary>
      private
System.ComponentModel.Container components =
null;

      public
Form1()
     
{
        
//
         // Required for Windows
Form Designer support
        
//
        
InitializeComponent();

        
//
         // TODO: Add any
constructor code after InitializeComponent
call
        
//
      }

      ///
<summary>
      /// Clean up any resources
being used.
      ///
</summary>
      protected override void
Dispose( bool disposing )
     
{
         if( disposing
)
        
{
           
if(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.button1 = new
System.Windows.Forms.Button();
        
this.label1 = new
System.Windows.Forms.Label();
        
this.SuspendLayout();
         //

         //
button1
         //

         this.button1.Location = new
System.Drawing.Point(150,
66);
         this.button1.Name =
"button1";
         this.button1.Size
= new System.Drawing.Size(157,
25);
         this.button1.TabIndex =
0;
         this.button1.Text = "Pick
points";
         this.button1.Click
+= new
System.EventHandler(this.button1_Click);
        
//
         //
label1
         //

         this.label1.AutoSize =
true;
         this.label1.Location =
new System.Drawing.Point(162,
119);
         this.label1.Name =
"label1";
         this.label1.Size =
new System.Drawing.Size(35,
16);
         this.label1.TabIndex =
1;
         this.label1.Text =
"label1";
         //

         //
Form1
         //

         this.AutoScaleBaseSize =
new System.Drawing.Size(5,
13);
         this.ClientSize = new
System.Drawing.Size(450,
182);
        
this.Controls.Add(this.label1);
        
this.Controls.Add(this.button1);
        
this.Name = "Form1";
        
this.Text = "Form1";
        
this.ResumeLayout(false);

     
}
     
#endregion


     
[CommandMethod("GetPointTest")]
      public static
void GetPointTest()
     
{
         using( Form1 form = new
Form1() )
           
AcadApp.ShowModalDialog(form);                 

      }

     
private void button1_Click(object sender, System.EventArgs
e)
     
{
         Editor editor =
AcadApp.DocumentManager.MdiActiveDocument.Editor;
        
ArrayList list = new
ArrayList();
        
PromptPointOptions opts = new
PromptPointOptions();
        
opts.Message = "\nNext point (or ENTER when done):
";
         opts.AllowNone =
true;
         this.Visible =
false;
        
try
        
{
            while(
true )
           
{
              
PromptPointResult res =
editor.GetPoint(opts);
              
if( res.Status != PromptStatus.OK
)
                 
break;

              
list.Add(res.Value);
           
}
        
}
        
finally
        
{
           
this.Visible =
true;
           
label1.Text = string.Format("{0} points picked",
list.Count);
        
}
      }
   }
}


--


size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2><CougerAC> wrote in message

href="news:5064254@discussion.autodesk.com">
size=2>news:5064254@discussion.autodesk.com

size=2>...
Maksim,

I have created a simple project that may help
you.

If you are prompting the user, you don't need to hide a
form.
AutoCAD will hide it when you call the editor.get???
methods.

Let me know if it works or not.

C
Message 11 of 25
Anonymous
in reply to: Anonymous


It's almost
identical to example code you've sent. Here it is:

 

<CommandMethod("TestCommand")>
_

Public
size=2>
Sub
DisplayForm()

  
Dim
 Form
size=2>As 
New
MyForm

  
class=205360014-19012006>
class=205360014-19012006>
size=2>Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(Form)


color=#0000ff>
class=205360014-19012006>

face="Courier New">End
Sub

 

Form has a button which hides it (
face="Courier New">Me.Hide
), but this is handled via MyForm's
class event handlers.
Even if I create
new object that displays my form within specified command handler
- it should run within defined execution context
neverthless. Could you explain what code do you consider "out of
execution context"?

 

Regards,

Maksim Sestic

 

 

 

Is the code that
calls ShowModalDialog() executed from
a registered command handler, or
something else?

Your problem is most likely that your form is being
shown
by code that's running in the wrong execution context.

--


size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Maksim Sestic" <

face=Verdana size=2>info@geoinova.com
>
wrote in message

face=Verdana size=2>news:5063409@discussion.autodesk.com

face=Verdana size=2>...
No, it didn't help. Annoying flickering (ACAD looses
focus and then regains it) still happening. It seems to me that
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog implementation,
which is (I believe) based on AutoCAD's Application Form, passes certain events
to it's parent without some handy overriding.
 
How about a third
constructor of ShowModaDialog:
Public Shared Function ShowModalDialog(ByVal
owner As System.Windows.Forms.IWin32Window, ByVal formToShow As
System.Windows.Forms.Form, ByVal persistSizeAndPosition As Boolean) As
System.Windows.Forms.DialogResult

When should I use it? 

 
Regards,
Maksim Sestic
 
<Jimmie Fulton> wrote
in message

face=Verdana size=2>news:5063304@discussion.autodesk.com

face=Verdana size=2>...
Does this work better for you?

Form.Visible =
False
' Do Something
Form.Visible = True
Message 12 of 25
cgay
in reply to: Anonymous

Maksim,
As far as the code I sent goes, if you do not want AutoCAD to handle the hiding/showing of the form, just put a me.visible=false at the beginning of the event handler, and a me.visible=true at the end of it.

Also, I have noticed the flickering, but only in explorer windows that have been opened AFTER AutoCAD has been launched. Do you see this same behavior?

C
Message 13 of 25
Anonymous
in reply to: Anonymous


Yeah, that's it
:-)

 

Maksim,
As far as the code I
sent goes, if you do not want AutoCAD to handle the hiding/showing of the form,
just put a me.visible=false at the beginning of the event handler, and a
me.visible=true at the end of it.

Also, I have noticed the flickering,
but only in explorer windows that have been opened AFTER AutoCAD has been
launched. Do you see this same behavior?

C
Message 14 of 25
Anonymous
in reply to: Anonymous

Looks like you caught a bug. I just noticed the same
problem you cite, with my test code. It only seems to
happen with windows that are created while AutoCAD
is running.

I have no idea why they're doing this, but it certainly
isn't pretty and looks very unprofessional.

I have a bit of a problem with Autodesk not fixing API
defects, in cases where the manifestation results in
making our applications look as unprofessional as this
defect seems to do. While the defect isn't 'critical',
it makes your solutions look very unprofessional, and
that's not good.

I expect better than what we're seeing in the way of
'quirks' in the managed wrapper API.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Maksim Sestic" wrote in message news:5064496@discussion.autodesk.com...
Tony's right, I need to pick several points (as explained in my previous post) and don't want to rely on AutoCAD showing/hiding my ModalDialog consequently. Try to reproduce that odd behaviour via:

1) Open few Explorer windows and let them remain open
2) Run AutoCAD and NETLOAD Tony's library (ACAD keeps focus)
3) Run GetPointTest command (now Form1 gets displayed and keeps focus)
4) Click the button to start points acquisition - what happens then?

4.1) Form1 gets hidden
4.2) ACAD's main window looses it's focus for a second, enough time to see opened windows in step 1)
4.3) ACAD's main window regains focus and lets you pick points...

Pretty odd behaviour.

Regards,
Maksim Sestic





"Tony Tanzillo" wrote in message news:5064392@discussion.autodesk.com...
>> If you are prompting the user, you don't need to hide a form.
>> AutoCAD will hide it when you call the editor.get??? methods.

Yes it will, but if the form is already hidden, then
the GetXxxx method should do nothing.

It needs to work that way because there's cases
where I may want to prompt for several values
while the form remains hidden, so repeatedly
showing/hiding it between each successive input
request isn't going to work well in that case
(for example, the Hatch dialog's "Add Pick points"
button works like that).

A simple test (C#, with nothing but a form with
a single button and label on it) seems to confirm
that the form can be hidden and shown manually,
without relying on the call to GetPoint() to do it
for you:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace ExtensionApplication1
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

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

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(150, 66);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(157, 25);
this.button1.TabIndex = 0;
this.button1.Text = "Pick points";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(162, 119);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 16);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(450, 182);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion


[CommandMethod("GetPointTest")]
public static void GetPointTest()
{
using( Form1 form = new Form1() )
AcadApp.ShowModalDialog(form);
}

private void button1_Click(object sender, System.EventArgs e)
{
Editor editor = AcadApp.DocumentManager.MdiActiveDocument.Editor;
ArrayList list = new ArrayList();
PromptPointOptions opts = new PromptPointOptions();
opts.Message = "\nNext point (or ENTER when done): ";
opts.AllowNone = true;
this.Visible = false;
try
{
while( true )
{
PromptPointResult res = editor.GetPoint(opts);
if( res.Status != PromptStatus.OK )
break;

list.Add(res.Value);
}
}
finally
{
this.Visible = true;
label1.Text = string.Format("{0} points picked", list.Count);
}
}
}
}


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5064254@discussion.autodesk.com...
Maksim,

I have created a simple project that may help you.

If you are prompting the user, you don't need to hide a form.
AutoCAD will hide it when you call the editor.get??? methods.

Let me know if it works or not.

C
Message 15 of 25
Anonymous
in reply to: Anonymous


Tony, this one looks sooo non-critical that I'm
expecting it to get fixed in AutoCAD 2008 :-)))

 

Regards,

Maksim Sestic

 

 

Looks like you
caught a bug.  I just noticed the same
problem you cite, with my test
code. It only seems to
happen with windows that are created while
AutoCAD
is running.

I have no idea why they're doing this, but it
certainly
isn't pretty and looks very unprofessional.

I have a bit of
a problem with Autodesk not fixing API
defects, in cases where the
manifestation results in
making our applications look as unprofessional as
this
defect seems to do.  While the defect isn't 'critical',
it
makes your solutions look very unprofessional, and
that's not good.

I
expect better than what we're seeing in the way of
'quirks' in the managed
wrapper API.

--

face=Verdana size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Maksim Sestic" <

face=Verdana size=2>info@geoinova.com
>
wrote in message

face=Verdana size=2>news:5064496@discussion.autodesk.com

face=Verdana size=2>...
Tony's right, I need to pick several points (as
explained in my previous post) and don't want to rely on AutoCAD showing/hiding
my ModalDialog consequently. Try to reproduce that odd behaviour
via:
 
1) Open few Explorer windows and let them remain open
2)
Run AutoCAD and NETLOAD Tony's library (ACAD keeps focus)
3) Run GetPointTest
command (now Form1 gets displayed and keeps focus)
4) Click the button to
start points acquisition - what happens then?
 
4.1) Form1 gets
hidden
4.2) ACAD's main window looses it's focus for a second, enough time to
see opened windows in step 1)
4.3) ACAD's main window regains focus and lets
you pick points...
 
Pretty odd
behaviour.
 
Regards,
Maksim
Sestic
 
 
 
 
 
"Tony Tanzillo"
<

size=2>tony.tanzillo@U_KNOW_WHERE.com
>
wrote in message

face=Verdana size=2>news:5064392@discussion.autodesk.com

face=Verdana size=2>...
>> If you are prompting the user, you don't
need to hide a form.
>> AutoCAD will hide it when you call the
editor.get??? methods.

Yes it will, but if the form is already hidden,
then
the GetXxxx method should do nothing. 

It needs to work
that way because there's cases
where I may want to prompt for several values

while the form remains hidden, so repeatedly
showing/hiding it between
each successive input
request isn't going to work well in that case
(for
example, the Hatch dialog's "Add Pick points"
button works like
that).

A simple test (C#, with nothing but a form with
a single button
and label on it) seems to confirm
that the form can be hidden and shown
manually,
without relying on the call to GetPoint() to do it
for
you:

using System;
using System.Drawing;
using
System.Collections;
using System.ComponentModel;
using
System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using
Autodesk.AutoCAD.ApplicationServices;
using
Autodesk.AutoCAD.EditorInput;
using AcadApp =
Autodesk.AutoCAD.ApplicationServices.Application;

namespace
ExtensionApplication1
{
   /// <summary>
  
/// Summary description for Form1.
   ///
</summary>
   public class Form1 :
System.Windows.Forms.Form
   {
     
private System.Windows.Forms.Button button1;
     
private System.Windows.Forms.Label label1;
      ///
<summary>
      /// Required designer
variable.
      ///
</summary>
      private
System.ComponentModel.Container components =
null;

      public
Form1()
     
{
        
//
         // Required for Windows
Form Designer support
        
//
        
InitializeComponent();

        
//
         // TODO: Add any
constructor code after InitializeComponent
call
        
//
      }

      ///
<summary>
      /// Clean up any resources
being used.
      ///
</summary>
      protected override void
Dispose( bool disposing )
     
{
         if( disposing
)
        
{
           
if(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.button1 = new
System.Windows.Forms.Button();
        
this.label1 = new
System.Windows.Forms.Label();
        
this.SuspendLayout();
         //

         //
button1
         //

         this.button1.Location = new
System.Drawing.Point(150,
66);
         this.button1.Name =
"button1";
         this.button1.Size
= new System.Drawing.Size(157,
25);
         this.button1.TabIndex =
0;
         this.button1.Text = "Pick
points";
         this.button1.Click
+= new
System.EventHandler(this.button1_Click);
        
//
         //
label1
         //

         this.label1.AutoSize =
true;
         this.label1.Location =
new System.Drawing.Point(162,
119);
         this.label1.Name =
"label1";
         this.label1.Size =
new System.Drawing.Size(35,
16);
         this.label1.TabIndex =
1;
         this.label1.Text =
"label1";
         //

         //
Form1
         //

         this.AutoScaleBaseSize =
new System.Drawing.Size(5,
13);
         this.ClientSize = new
System.Drawing.Size(450,
182);
        
this.Controls.Add(this.label1);
        
this.Controls.Add(this.button1);
        
this.Name = "Form1";
        
this.Text = "Form1";
        
this.ResumeLayout(false);

     
}
     
#endregion


     
[CommandMethod("GetPointTest")]
      public static
void GetPointTest()
     
{
         using( Form1 form = new
Form1() )
           
AcadApp.ShowModalDialog(form);                 

      }

     
private void button1_Click(object sender, System.EventArgs
e)
     
{
         Editor editor =
AcadApp.DocumentManager.MdiActiveDocument.Editor;
        
ArrayList list = new
ArrayList();
        
PromptPointOptions opts = new
PromptPointOptions();
        
opts.Message = "\nNext point (or ENTER when done):
";
         opts.AllowNone =
true;
         this.Visible =
false;
        
try
        
{
            while(
true )
           
{
              
PromptPointResult res =
editor.GetPoint(opts);
              
if( res.Status != PromptStatus.OK
)
                 
break;

              
list.Add(res.Value);
           
}
        
}
        
finally
        
{
           
this.Visible =
true;
           
label1.Text = string.Format("{0} points picked",
list.Count);
        
}
      }
   }
}


--


size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2><CougerAC> wrote in message

href="news:5064254@discussion.autodesk.com">
size=2>news:5064254@discussion.autodesk.com

size=2>...
Maksim,

I have created a simple project that may help
you.

If you are prompting the user, you don't need to hide a
form.
AutoCAD will hide it when you call the editor.get???
methods.

Let me know if it works or not.

C
Message 16 of 25
NathTay
in reply to: Anonymous

Has anyone found a workaround/solution.

Regards - Nathan
Message 17 of 25
Anonymous
in reply to: Anonymous

Not yet 🙂

wrote in message news:5407830@discussion.autodesk.com...
Has anyone found a workaround/solution.

Regards - Nathan
Message 18 of 25
NathTay
in reply to: Anonymous

The problem does not occur if you minimize the windows so I tried a few approaches to do that. But they had their own problems. One approach resulted in the AutoCAD screen and my form maximised but without focus and the other that did not result in this but displayed the windows as they were minimized.

I have resigned to living with it and hope it will be fixed in 2008.

Regards - Nathan
Message 19 of 25
Rob.O
in reply to: Anonymous

Sorry to bring an old post back from the dead, but I was having this same issue and found this thread. I cannot beleive that I am still seeing this issue (Explorer windows opened after AutoCAD has been started flicker on form hide) in AutoCAD 2011!

 

As someone mentioned, this does not occur if the windows are minimized first.

Message 20 of 25
matus.brlit
in reply to: Anonymous

i came across this thread while i was trying to solve a similar problem

 

I have a modal form, that shows a new modal form in a button.click event handler

 

    Private Sub MyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButton.Click

        Me.Hide()
        Dim modalForm As New MyForm()
        AcApp.ShowModalDialog(modalForm)
        Me.Show()

    End Sub

 

 

 

after MyForm is showed, i see it's window and the background is not AutoCAD, but any application that was focused before AutoCAD

the only way to have it behave normally is to have all windows minimized, then the background for MyForm is AutoCAD

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost