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,