找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1486|回复: 0

ObjectARX Technical Newsletter - March 2000

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-1-7 02:21:42 | 显示全部楼层 |阅读模式

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

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

×
ObjectARX Technical Newsletter - March 2000  
This document is part of    ObjectARX Newsletter Archive     



/Note: Have you missed a Newsletter issue? Visit our Newsletter archive at
the following URL:/

http://adn.autodesk.com/techsupp/docs/newsletters.htm

Dear ObjectARX developer,

Table of Content
================

1. ARX/DBX dependencies loading problem in AutoCAD and in general.
2. AutoCAD 2000 defect when implementing an MFC document template in
   the AutoCAD application.
3. New and Updated Solutions
  

1. ARX/DBX dependencies loading problem in AutoCAD and in general.
------------------------------------------------------------------
One of the problem you may have when developing an ARX/DBX application
which is composed in several modules, or which uses other DLLs, is that
you may get the following annoying message "MyApplication.arx cannot find
a dll or other file that it needs.". This message can appear in applications
other than AutoCAD, but in AutoCAD you would also see the following on the
command line: "AcRxDynamicLinker failed to load 'XXX.arx'".
The first message is generated from the OS, while the second is generated
from the AutoCAD kernel. AutoCAD is using the ::LoadLibrary() Win32 API to
load an ARX/DBX application in its kernel, but if ::LoadLibrary() fails to
load the application because a dependency is not found, AutoCAD cannot
determine why this operation failed, in this case ::LoadLibrary() just
returns a NULL value. This is why the AutoCAD message is not really clear
compared to the one generated by the OS. What do you need to do in order
for your application loads properly in AutoCAD? The solution is simple but
not always easy to apply. The rule is that the OS needs to find your DLL,
so you need to make sure that your DLL is in the OS 'Search Path'
(not necessary the AutoCAD 'Search Path' which is a different thing).
So where? You have 2 standard options here. Either you put your DLLs into
an existing folder which is already in the OS Search Path
(i.e. "C:\Program Files\Common files\Autodesk Shared'), or you add your
application folder to the path variable. This last option requires that
you modify the OS settings during installation.
A third option is available to you as well and is explained in the
solution below.

Delay-loading .DBX modules from .ARX - no more Windows path grief!

Question:
I have an ObjectARX User Interface (.ARX) module which has dependency on
an ObjectDBX Object Enabler (.DBX) module. I link the .ARX with the .DBX's
import library (.LIB). The .DBX demand-loads correctly on proxy detection,
but the .ARX will not demand-load on command invocation. I get the
following error. MyApplication.arx cannot find a dll or other file that it
needs. If I add the location of the .DBX to the Windows system path or
install it into C:\Program Files\Common Files\Autodesk Shared then it works
fine, but I want to avoid that.

Answer:
There is a mechanism available in Visual C++ 6 called "delay loading". This
mechanism allows you to link to a library via the standard DLL linking
mechanism, but to delay its initialization until required.

To specify that your .ARX delay-loads your .DBX, edit your .ARX project's
linker settings:

1) Add the following library to the "Object/library modules" list:
   delayimp.lib
2) Specify this setting (manually) in the "Project Options" text-box:
   /delayload:"MyDbxModule.dbx"

You will now be able to demand-load both the .ARX module and the .DBX
without being constrained by the Windows system path. You will need to
load the DBX application programmatically from the ARX application for
this technique to work - use either acrxLoadModule() or
acrxDynamicLinker->loadModule().

Be warned that there are some limitations to this method, such as not
being able to access data directly in the .DBX module, but these are
all documented clearly on MSDN.
  
  

2. AutoCAD 2000 defect when implementing an MFC document template in
   -----------------------------------------------------------------
   the AutoCAD application.
   ------------------------

Since AutoCAD r13, the AutoCAD Window environment was based on the
MFC MDI feature. However, in AutoCAD r13 it was not possible to
create new MFC document template into the AutoCAD environment since
AutoCAD r13 was statically linked with MFC. With AutoCAD r14 which
uses MFC Shared DLLs, it was possible and therefore possible to
create a new MFC document template to have a multiple document
application user interface. Unfortunately, the AutoCAD 2000 shipping
release has a defect which prevents this from work properly. The problem
shows-up whenever you close a DWG file when another document type is
taking the focus, or (but less important) if your document view do not
implement the OnPaint() method. In you do not implement the workaround
below, AutoCAD will crash immediately with an 'Unhandled Exception Error'
and you will not be able to save your modified DWG.

The solution to fix this particular problem is to implement an
AcApDocManagerReactor::documentToBeDestroyed() reactor notification
as follows:

void AsdkT098MDIBUGFix::documentToBeDestroyed(AcApDocument* pDocToDestroy) {
//----- In case there is no more DWG document opened
//----- there is no other choice than
//----- closing all other MFC documents.
//----- These 2 lines force a close of all document of a specific
//----- MFC document template
//----- represented by 'pDocTemplate' to save & close silently.
if ( acDocManager->documentCount () == 1 )
  pDocTemplate->CloseAllDocuments (TRUE) ;

//----- The lines below will insure that the document taking
//----- the focus will be an DWG document.
AcApDocumentIterator *pi =acDocManager->newAcApDocumentIterator () ;
while ( !pi->done () ) {
  if ( pi->document () == pDocToDestroy ) {
   POSITION pos =pi->document ()->cDoc
()->GetFirstViewPosition () ;
   CView *pView =pi->document ()->cDoc ()->GetNextView
(pos) ;
   while ( acedGetAcadFrame ()->MDIGetActive () !=
pView->GetParent () )
    acedGetAcadFrame ()->MDINext () ;
   break ;
  }
  pi->step () ;
}
delete pi ;
}

Also you document CView class must implement 'OnPaint()'.
  

3. New and Updated Solutions
----------------------------

New and updated solutions are available at:
http://adn.autodesk.com/techsupp/adnkb/whatsnew1.htm
or
http://adn.autodesk.com/techsupp/adnkb/whatsnew2.htm

-----------------------------------------------------------------------------
To subscribe or unsubscribe, go to
http://adn.autodesk.com/techsupp/docs/newsletters.htm
-----------------------------------------------------------------------------

     You received this message as a result of your registration
     on the ADN List Server subscription page.  If you no longer wish
     to receive these messages, read the next section, How to use this
     mailing list.

     How to use this mailing list:

     You may unsubscribe from this e-mail newsletter, or subscribe to
     a variety of other informative e-mail newsletters, by returning
     to the ADN List Server subscription page at
       http://adn.autodesk.com/techsupp/docs/newsletters.htm
     and changing your subscription preferences.

     Alternatively, from the subscribed account you can send an e-mail to
     <Majordomo-partnersys@autodesk.com> with the following command in the
     body of your email message:

     unsubscribe <list-name>

     ----------------------------------------------------------------------

     Autodesk Developer Network (ADN) information and events:

     For information on all ADN topics, please visit:
       http://www.autodesk.com/adn

     ----------------------------------------------------------------------

     THIS DOCUMENT IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.  The
     information contained in this document represents the current view of
     Autodesk Inc. on the issues discussed as of the date of publication.
     Because Autodesk must respond to change in market conditions, it
     should not be interpreted to be a commitment on the part of Autodesk
     and Autodesk cannot guarantee the accuracy of any information
     presented after the date of publication.
     INFORMATION PROVIDED IN THIS DOCUMENT IS PROVIDED 'AS IS' WITHOUT
     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
     LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
     PARTICULAR PURPOSE AND FREEDOM FROM INFRINGEMENT.
     The user assumes the entire risk as to the accuracy and the use of
     this document. This  document may be copied and distributed subject to
     the following conditions:
     1.   All text must be copied without modification and all pages must
          be included
     2.   All copies must contain Autodesk's copyright notice and any other
          notices provided therein
     3.   This document may not be distributed for profit
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-12-25 02:21 , Processed in 0.385313 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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