如何实现正正中绘制柱的功能:非模式窗口中,即时中断当前命令
<p>如何实现正正中绘制柱的功能:非模式窗口中,即时中断当前命令</p><p>想做一个天正画柱子的对话框在线更改参数的功能,但前一个命令(如画圆,或ThisDrawing.Utility.GetPoint(, "Enter a point: ")<br/>等),并如何取消这个命令</p><p> </p><p><a href="http://www.mjtd.com/bbs/showimg.asp?BoardID=4&fileid=49474"></a></p> <p>1,显示非模式对话框,这个张帆的教程有写</p><p>2,绘制部分,关键在于坐标的传递,图形的实现不难</p> 在使用GETXXX系列函数时,需要先中断原有命令,不然会变成嵌套了,这次命令完成后,还会执行上一个命令。 这个有难度么?//Sol1
retcode = getXXX;
while( RTNORM == retcode )
{
//codes
retcode = GetXXX
}
//sol2
while( RTNORM == getXXX )
{ //Add your codes
}
至于如何显示对话框,你根据你的需要,响应对话框的消息。
对于简单的模式对话框,使用宏beginEditorCommand()来暂时隐藏当前对话框,cancleEditorCommand()或completeEditorCommand()来显示当前对话框。
还是没有解决,本想做一个和天正的这个功能类似的参数设置界面,在不关闭界面的情况下即时绘图,即时切换GET*系列的 <p>楼主绕来绕去,还不是说要做个非模态的对话框?mfc教程有这方面的例子!</p> <p>主要是与CAD交互</p><p>在晓东找了个帖子:</p><p>1. 如果在非模式对话框中放一个按扭,点按扭时执行: acedSSGet(...) 函数, 当我按下按扭后,不选择对象(但此时acedSSGet 函数已执行).由于是非模式对话框,我还可以继续点按扭,当点的次数很多时,系统就出错了<br/><br/>我想在第二次点按扭时,如果前一个按扭没有完成任务(这可以判断出来),就终止前一个任务,执行这个新的任务,就像发送一个ESC消息一样,怎么办<br/><br/>2. 在非模式对话框中放一个按扭,按扭执行: acedPrompt("....") ,当提示完成后,我想让命令行回到原始状态,即"命令: " , 如果就简单在acedPrompt("\n.....\n",好象不行,请指教</p><p></p><p>回</p><p></p><p><table height="100%"><tbody><tr><td colspan="2">如何在MFC“非模式”对话框使用acedGetXXX函数和ACAD交互<br/>How can I use ads_getxxx() functions from a MFC modeless dialog box ? <br/>ID 2125 <br/>Applies to: AutoCAD <br/><br/>Date 6/19/2000 <br/><br/>This document is part of MFC <br/><br/><br/>Question <br/>How can I use ads_getXXX() functions from an MFC modeless dialog box?<br/>Answer <br/>Your code will work properly if you call ads_getXXX() functions directly from an<br/>MFC modeless dialog box handler function because AutoCAD sends the<br/>WM_ACADKEEPFOCUS message to your dialog at the same time you are in the handler<br/>function where you want to make an ads_getpoint(). Then when you pick a point,<br/>you send a WM_LBUTTONDOWN message which goes in the window message queue as<br/>well. But this message does not proceed until you came back to AutoCAD. After<br/>you have come back, the message proceeds. Then you need to give two points where<br/>onlyy one error occurs. This is why AutoCAD asks for the other corner.<br/><br/>Another problem is that modeless windows may try to execute code at the same<br/>time an AutoCAD command is running. This will produce some errors and may cause<br/>AutoCAD to terminate unexpectedly. The reason is that modeless windows have<br/>their own message loop, and while AutoCAD is busy, you must not call any AutoCAD<br/>function. AutoCAD is not design to run in that context.<br/><br/>To solve these problems, move the code contained into this handler function into<br/>a standalone ARX command / function. Then from the button handler function, you<br/>can send a WM_COPYDATA message to AutoCAD to invoke this command which will do<br/>the job.<br/><br/>1. When the button is pressed, the button handler function code is executed. You<br/>need to do the following:<br/>-- hide the dialog<br/>-- change my WM_ACAD_KEEPFOCUS handler function to return FALSE<br/>-- give the focus to the AutoCAD main frame window<br/>-- use the acedGetAcadFrame ()->PostMessage(WM_SETFOCUS, 0L, 0L) method<br/>-- send the WM_COPYDATA message to the main AutoCAD frame window with the<br/>command name (myfunc, for example)<br/><br/>2. In the myfunc function (defined as an ARX command), then perform these steps:<br/>-- put all the code you need to acquire a point<br/>-- post a custom user message (WM_USER+1, for example) to your dialog with the<br/>point in the LPARAM as parameter<br/><br/>3. In the handler of the WM_USER+1 message, perform these steps:<br/>-- change my WM_ACAD_KEEPFOCUS handler function to return TRUE again<br/>-- show the dialog, and give the focus to it<br/> </td></tr><tr><td valign="bottom" colspan="2"><br/></td></tr></tbody></table></p><p>慢慢看中ing.....</p> <p>1. 如果在非模式对话框中放一个按扭,点按扭时执行: acedSSGet(...) 函数, 当我按下按扭后,不选择对象(但此时acedSSGet 函数已执行).由于是非模式对话框,我还可以继续点按扭,当点的次数很多时,系统就出错了<br/><br/>我想在第二次点按扭时,如果前一个按扭没有完成任务(这可以判断出来),就终止前一个任务,执行这个新的任务,就像发送一个ESC消息一样,怎么办</p><p>刚才试验了一下,没难度,只要在这个对话框加个成员变量,假定为bool型,初始化为true,只要这个对话框还在,这个变量就存在,在按钮执行命令一开始,就检测这个变量的值,只要是false,就rerurn,如果为true,就马上让他为false,然后调用getXXX,代码最后将这个变量设为true,这样就可以避免啦,</p><p>void ModelessDLG::OnBnClickedButton1()<br/>{<br/> // 参考代码 if ( m_cmdStatus == false ) <br/>if ( m_cmdStatus == false )<br/> {<br/> AfxMessageBox(L"command in progress! ");<br/> return;<br/> }<br/> m_cmdStatus=false;<br/> ads_point pt;<br/> ads_name name;<br/> acedEntSel(L"pick an entity:\n", name, pt );<br/> m_cmdStatus = true;<br/>}[/CODE</p><p></p><p>针对多个命令,或者是不同对话框的命令,可以设置全局变量来考虑,但是,【取消上一个命令,我还不了解机里】</p> <p>这只是判断当前是否在命令状态下,在的话则返回,</p><p>需要的是判断在的话,则中断当前GETXX,重新开始新的GETXX</p> 我遇到了和你一样的问题<div>命令嵌套超过四层就会出错,就算不出错,一层层往外跳也不好</div><div>请问楼主这个问题解决了没有?</div>
页:
[1]
2