- UID
- 33731
- 积分
- 1055
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-3-6
- 最后登录
- 1970-1-1
|
发表于 2009-9-17 22:32:04
|
显示全部楼层
最近我在找这个,但看不明白
http://www.xdcad.net/forum/showthread.php?postid=9956#post9956
如何在MFC“非模式”对话框使用acedGetXXX函数和ACAD交互
How can I use ads_getxxx() functions from a MFC modeless dialog box ?
ID 2125
Applies to: AutoCAD
Date 6/19/2000
This document is part of MFC
Question
How can I use ads_getXXX() functions from an MFC modeless dialog box?
Answer
Your code will work properly if you call ads_getXXX() functions directly from an
MFC modeless dialog box handler function because AutoCAD sends the
WM_ACADKEEPFOCUS message to your dialog at the same time you are in the handler
function where you want to make an ads_getpoint(). Then when you pick a point,
you send a WM_LBUTTONDOWN message which goes in the window message queue as
well. But this message does not proceed until you came back to AutoCAD. After
you have come back, the message proceeds. Then you need to give two points where
onlyy one error occurs. This is why AutoCAD asks for the other corner.
Another problem is that modeless windows may try to execute code at the same
time an AutoCAD command is running. This will produce some errors and may cause
AutoCAD to terminate unexpectedly. The reason is that modeless windows have
their own message loop, and while AutoCAD is busy, you must not call any AutoCAD
function. AutoCAD is not design to run in that context.
To solve these problems, move the code contained into this handler function into
a standalone ARX command / function. Then from the button handler function, you
can send a WM_COPYDATA message to AutoCAD to invoke this command which will do
the job.
1. When the button is pressed, the button handler function code is executed. You
need to do the following:
-- hide the dialog
-- change my WM_ACAD_KEEPFOCUS handler function to return FALSE
-- give the focus to the AutoCAD main frame window
-- use the acedGetAcadFrame ()->PostMessage(WM_SETFOCUS, 0L, 0L) method
-- send the WM_COPYDATA message to the main AutoCAD frame window with the
command name (myfunc, for example)
2. In the myfunc function (defined as an ARX command), then perform these steps:
-- put all the code you need to acquire a point
-- post a custom user message (WM_USER+1, for example) to your dialog with the
point in the LPARAM as parameter
3. In the handler of the WM_USER+1 message, perform these steps:
-- change my WM_ACAD_KEEPFOCUS handler function to return TRUE again
-- show the dialog, and give the focus to it |
|