Hi,
To use the standard MessageBox, you can simply build a simple LispFunction method:
[LispFunction("messagebox")]
public bool MessagegBox(ResultBuffer resbuf)
{
if (resbuf != null)
{
var arg = resbuf.AsArray()[0];
if (arg.TypeCode == (int)LispDataType.Text)
{
MessageBox.Show(arg.Value.ToString());
return true;
}
}
return false;
}
Usage:
(messagebox "Total length of selected objects is 1523.401")
If you want to use a "custom" message box, you can use the same way.
A trivial example of custom message box:
public class MsgBox : Form
{
public MsgBox(string msg)
{
Size = new System.Drawing.Size(250, 110);
StartPosition = FormStartPosition.CenterParent;
Text = "Message from LISP";
FormBorderStyle = FormBorderStyle.FixedDialog;
AutoSize = true;
MinimizeBox = false;
MaximizeBox = false;
Controls.Add(new Label()
{
AutoSize = true,
Location = new System.Drawing.Point(13, 13),
Text = msg
});
Controls.Add(new Button
{
DialogResult = DialogResult.OK,
Location = new System.Drawing.Point(80, 37),
Text = "OK"
});
}
}
The LISP function:
[LispFunction("msgbox")]
public bool MsgBox(ResultBuffer resbuf)
{
if (resbuf != null)
{
var arg = resbuf.AsArray()[0];
if (arg.TypeCode == (int)LispDataType.Text)
{
using (var dlg = new MsgBox(arg.Value.ToString()))
{
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(dlg);
}
return true;
}
}
return false;
}
Usage:
(msgbox "Total length of selected objects is 1523.401")