chpmould 发表于 2010-11-11 20:08:00

[求助]非模式窗口

<p><font face="Verdana">请教各位老师</font></p>
<p><font face="Verdana">我在使用非模式窗口时,点确认按钮时,窗体设为不用关闭的情况下,程序没有任何反映,是什么原因?</font></p>
<p><font face="Verdana">Application.<font color="#0000ff">ShowModelessDialog</font>(fm)</font></p>

雪山飞狐_lzh 发表于 2010-11-11 20:30:00

问题是,你的代码呢

chpmould 发表于 2010-11-11 21:23:00

   
static public void DrawCircle()
{
ClassLibrary1.TestForm Dg = new ClassLibrary1.TestForm();
Application.ShowModelessDialog(Dg);
if (Dg.DialogResult== System.Windows.Forms.DialogResult.Cancel)
{
ed.WriteMessage("\n");
return;
}
using (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointOptions p = new PromptPointOptions("");
p.Message = "请选取圆心!";
PromptPointResult result = ed.GetPoint(p);
if (result.Status.ToString() == "OK")
{
Point3d centerPoint = result.Value;
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
using (Transaction acTrans = acDoc.TransactionManager.StartTransaction())
{
BlockTable acTab = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = acTrans.GetObject(acTab, OpenMode.ForWrite) as BlockTableRecord;
Circle newCircle = new Circle();
newCircle.SetDatabaseDefaults();
newCircle.Center = centerPoint;
newCircle.Radius = 10;
acBlkTblRec.AppendEntity(newCircle);
acTrans.AddNewlyCreatedDBObject(newCircle, true);
acTrans.Commit();
}
}
}

雪山飞狐_lzh 发表于 2010-11-11 22:38:00

画圆的代码放在窗体的button1的单击事件里

chpmould 发表于 2010-11-12 12:29:00

<p>狐哥,</p>
<p>请问非模式窗口必须将程序放在窗体内吗?能否有其它方法可以让程序还是放在类内面,我想这样管理程序容易一些</p>

chpmould 发表于 2010-11-13 09:55:00

能否有其它方法可以让程序还是放在类内面?

sieben 发表于 2010-11-16 00:06:00

<p>对话框也是类,程序放在<font face="Verdana"><font face="Verdana">窗体内也就是放在类内</font></font></p>
<p>C#可以说全部代码都在类内</p>

chpmould 发表于 2010-11-16 00:35:00

<p>谢谢Sieben</p>
<p>我刚学C#,你能否帮我在我以上贴的绘制圆程序中添加进去啊...</p>
页: [1]
查看完整版本: [求助]非模式窗口