找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1721|回复: 1

[教学]:如何在MFC“非模式”对话框使用acedGetXXX函数和ACAD交互

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-3-10 09:40:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 1632个

财富等级: 堆金积玉

发表于 2013-5-1 15:17:31 | 显示全部楼层
很好的学习贴
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 10:28 , Processed in 0.375024 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表