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