.NET

Reply
Active Contributor
ae_louz
Posts: 32
Registered: ‎06-01-2006
Message 1 of 9 (203 Views)

Modeless problem

203 Views, 8 Replies
09-14-2006 04:41 AM
Hi all!

I have a little problem : when I minimize the autoCAD window, I still see my modeless dialogs in the desktop. ;(

Please is there a way to minimize them with their parent window(AutoCAD), or just close them. Something like events perhaps?

Sorry for my English and thanks in advance for anyone who can help.

Aymen,
*Paul Richardson
Message 2 of 9 (203 Views)

Re: Modeless problem

09-14-2006 05:00 AM in reply to: ae_louz
use ShowModelessDialog of the Application object.

wrote in message news:5328784@discussion.autodesk.com...
Hi all!

I have a little problem : when I minimize the autoCAD window, I still see my
modeless dialogs in the desktop. ;(

Please is there a way to minimize them with their parent window(AutoCAD), or
just close them. Something like events perhaps?

Sorry for my English and thanks in advance for anyone who can help.

Aymen,
Active Contributor
ae_louz
Posts: 32
Registered: ‎06-01-2006
Message 3 of 9 (203 Views)

Re: Modeless problem

09-14-2006 05:43 AM in reply to: ae_louz
Hi Paul!

The problem is that I'm using ShowModelessDialog...

Aymen,
*Paul Richardson
Message 4 of 9 (203 Views)

Re: Modeless problem

09-14-2006 06:00 AM in reply to: ae_louz
I don't know what's up. It works for me. Post the code you're using.

Also, do search for "ShowModelessDialog" Tony posted a nice example
which implements a singleton method.

wrote in message news:5328833@discussion.autodesk.com...
Hi Paul!

The problem is that I'm using ShowModelessDialog...

Aymen,
*Tony Tanzillo
Message 5 of 9 (203 Views)

Re: Modeless problem

09-15-2006 05:47 AM in reply to: ae_louz
We're not fortune tellers with crystal balls, so
we don't know what your code is doing without
seeing a reproducible case.

--
http://www.caddzone.com

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

wrote in message news:5328833@discussion.autodesk.com...
Hi Paul!

The problem is that I'm using ShowModelessDialog...

Aymen,
*Paul Richardson
Message 6 of 9 (203 Views)

Re: Modeless problem

09-15-2006 07:08 AM in reply to: ae_louz
And I thought you could do all. I need to
go rethink the universe. :-)
"Tony Tanzillo" wrote in message
news:5330428@discussion.autodesk.com...
We're not fortune tellers with crystal balls, so
we don't know what your code is doing without
seeing a reproducible case.

--
http://www.caddzone.com

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

wrote in message news:5328833@discussion.autodesk.com...
Hi Paul!

The problem is that I'm using ShowModelessDialog...

Aymen,
*Maksim Sestic
Message 7 of 9 (203 Views)

Re: Modeless problem

09-15-2006 07:09 AM in reply to: ae_louz
Try using second ShowModelessDialog constructor, passing ACAD window handle
as it's second parameter.

Regards,
Maksim Sestic

wrote in message news:5328784@discussion.autodesk.com...
Hi all!

I have a little problem : when I minimize the autoCAD window, I still see my
modeless dialogs in the desktop. ;(

Please is there a way to minimize them with their parent window(AutoCAD), or
just close them. Something like events perhaps?

Sorry for my English and thanks in advance for anyone who can help.

Aymen,
Active Contributor
ae_louz
Posts: 32
Registered: ‎06-01-2006
Message 8 of 9 (203 Views)

Re: Modeless problem

09-17-2006 08:15 AM in reply to: ae_louz
Hi all,

Sorry, I had some personal problems...(Now, it's Ok!)

This is the code, it is supposed to work like the acet-ui-status (a lisp command displaying a modeless dialog with custom text).

First file :
///----------------------------------------------------------------------

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

using Autodesk.AutoCAD.Runtime;


namespace TestNamespace
{
public class TestUiStatusClass
{
//Importing necessary DLLS

[DllImport("USER32.DLL")]
public static extern IntPtr SetFocus(System.IntPtr hwnd);


UiStatusForm TestForm = new UiStatusForm();

//Command Calls

[CommandMethod("UiStatus")]
public void showErr()
{
if (TestForm.Visible)
{ TestForm.Hide(); }
else
{
IWin32Window owner = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window;
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(owner, TestForm);

TestForm.Location = new System.Drawing.Point(200, 200);

Label label1 = new System.Windows.Forms.Label();
Label label2 = new System.Windows.Forms.Label();
////
//// label1
////
label1.AutoSize = true;
label1.BackColor = System.Drawing.Color.Transparent;
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
label1.Location = new System.Drawing.Point(70, 9);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(116, 24);
label1.TabIndex = 0;
label1.Text = "MessageTitle : ";
TestForm.Controls.Add(label1);
////
//// label2
////
label2.AutoSize = true;
label2.BackColor = System.Drawing.Color.Transparent;
label2.ForeColor = System.Drawing.Color.White;
label2.Location = new System.Drawing.Point(80, 24);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(273, 13);
label2.TabIndex = 1;
label2.Tag = "";
label2.Text = "\nTest text";
TestForm.Controls.Add(label2);

IntPtr hwnd = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle;
SetFocus(hwnd);
}
}
}
}

///----------------------------------------------------------------------
Second file:
///----------------------------------------------------------------------
using System.Windows.Forms;

namespace TestNamespace
{
///
/// Summary description for ModalForm.
///

public class UiStatusForm : System.Windows.Forms.Form
{

//private IContainer components;

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

//
// TODO: Add any constructor code after InitializeComponent call
//
}
private System.ComponentModel.Container components = null;
///
/// 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UiStatusForm));
this.SuspendLayout();
//
// UiStatusForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoSize = true;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
this.BackColor = System.Drawing.Color.Red;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));/// place any Background Image you want
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(270, 70);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximumSize = new System.Drawing.Size(320, 640);
this.MinimumSize = new System.Drawing.Size(270, 70);
this.Name = "UiStatusForm";
this.Opacity = 0.9;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.ResumeLayout(false);

}

#endregion

}
}

///----------------------------------------------------------------------


Thanks in advance and sorry again.

Aymen,
*Maksim Sestic
Message 9 of 9 (203 Views)

Re: Modeless problem

09-19-2006 07:37 AM in reply to: ae_louz

Did you try with:

 


size=2>Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(Application.MainWindow,
TestForm);

Regards,

Maksim Sestic

 

 

Hi all,

Sorry, I had
some personal problems...(Now, it's Ok!)

This is the code, it is supposed
to work like the acet-ui-status (a lisp command displaying a modeless dialog
with custom text).

First file
:
///----------------------------------------------------------------------

using
System;
using System.Windows.Forms;
using
System.Runtime.InteropServices;

using
Autodesk.AutoCAD.Runtime;


namespace
TestNamespace
{
   public class
TestUiStatusClass
{
    //Importing necessary
DLLS

    [DllImport("USER32.DLL")]
   
public static extern IntPtr SetFocus(System.IntPtr hwnd);



    UiStatusForm TestForm = new
UiStatusForm();
    
    //Command
Calls

      
[CommandMethod("UiStatus")]
       public void
showErr()
      
{
           if
(TestForm.Visible)
          
{ TestForm.Hide();
}
          
else
          
{
              
IWin32Window owner =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window;
              
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(owner,
TestForm);

              
TestForm.Location = new System.Drawing.Point(200,
200);

              
Label label1 = new
System.Windows.Forms.Label();
              
Label label2 = new
System.Windows.Forms.Label();
              
////

              
////
label1
              
////

              
label1.AutoSize =
true;
              
label1.BackColor =
System.Drawing.Color.Transparent;
              
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
              
label1.Location = new System.Drawing.Point(70,
9);
              
label1.Name =
"label1";
              
label1.Size = new System.Drawing.Size(116,
24);
              
label1.TabIndex =
0;
              
label1.Text = "MessageTitle :
";
              
TestForm.Controls.Add(label1);
              
////

              
////
label2
              
////

              
label2.AutoSize =
true;
              
label2.BackColor =
System.Drawing.Color.Transparent;
              
label2.ForeColor =
System.Drawing.Color.White;
              
label2.Location = new System.Drawing.Point(80,
24);
              
label2.Name =
"label2";
              
label2.Size = new System.Drawing.Size(273,
13);
              
label2.TabIndex =
1;
              
label2.Tag =
"";
              
label2.Text = "\nTest
text";
              
TestForm.Controls.Add(label2);

              
IntPtr hwnd =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle;
              
SetFocus(hwnd);
          
}
       }
}
}


///----------------------------------------------------------------------
Second
file:
///----------------------------------------------------------------------
using
System.Windows.Forms;

namespace TestNamespace
{
///
<summary>
/// Summary description for ModalForm.
///
</summary>
    public class UiStatusForm :
System.Windows.Forms.Form
   
{

        //private IContainer
components;

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

//
// TODO: Add any
constructor code after InitializeComponent
call
//
       
}
        private
System.ComponentModel.Container components = null;
/// <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()
{
           
System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(UiStatusForm));
           
this.SuspendLayout();
           
//
            //
UiStatusForm
           
//
           
this.AutoScaleBaseSize = new System.Drawing.Size(5,
13);
           
this.AutoSize =
true;
           
this.AutoValidate =
System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
           
this.BackColor =
System.Drawing.Color.Red;
           
this.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));/// place
any Background Image you
want
           
this.BackgroundImageLayout =
System.Windows.Forms.ImageLayout.None;
           
this.ClientSize = new System.Drawing.Size(270,
70);
           
this.ForeColor =
System.Drawing.Color.White;
           
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None;
           
this.MaximumSize = new System.Drawing.Size(320,
640);
           
this.MinimumSize = new System.Drawing.Size(270,
70);
           
this.Name =
"UiStatusForm";
           
this.Opacity =
0.9;
           
this.ShowIcon =
false;
           
this.ShowInTaskbar =
false;
           
this.StartPosition =
System.Windows.Forms.FormStartPosition.Manual;
           
this.ResumeLayout(false);

}

#endregion      


}
}

///----------------------------------------------------------------------


Thanks
in advance and sorry again.

Aymen,
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.