CR的代码文本

all for learning about the world
  订阅 订阅  :: 管理

入口点函数的19种消息,AcRxArxApp只处理16种。

Posted on 2013-12-05 15:02  mumuliang  阅读(1659)  评论(2编辑  收藏  举报

AcRx::AppMsgCode一共有19种消息。

但由IMPLEMENT_ARX_ENTRYPOINT宏实现的App类,只处理了16种消息。

缺:

    kSuspendMsg = 16,
    kInitTabGroupMsg = 17,
    kEndTabGroupMsg = 18

 

Messages that are sent to all applications

Messages that are sent only if the application has registered an AutoLISP ® function with acedDefun()

Messages that are sent to applications that have registered a service with ObjectARX

Messages only responded to by applications that use ActiveX Automation

 

  enum AppMsgCode {
    kNullMsg = 0,
    kInitAppMsg = 1,
    kUnloadAppMsg = 2,
    kLoadDwgMsg = 3,
    kUnloadDwgMsg = 4,
    kInvkSubrMsg = 5,
    kCfgMsg = 6,
    kEndMsg = 7,
    kQuitMsg = 8,
    kSaveMsg = 9,
    kDependencyMsg = 10,
    kNoDependencyMsg = 11,
    kOleUnloadAppMsg = 12,
    kPreQuitMsg = 13,
    kInitDialogMsg = 14,
    kEndDialogMsg = 15,
    kSuspendMsg = 16,
    kInitTabGroupMsg = 17,
    kEndTabGroupMsg = 18
  };

 

这个kPreQuitMsg看起来像有用的。

 

官方建议在消息响应中做的操作

Message

Recommended Actions

kInitAppMsg

Do register services, classes, AcEd commands and reactors, and AcRxDynamicLinker reactors. Initialize application's system resources, such as devices and windows. Perform all one-time early initialization. AcRx, AcEd, and AcGe are all active. Store the value of the pkt parameter if you want to unlock and relock your application. 

Don't expect device drivers to be initialized, any user interface resources to be active, applications to be loaded in a particular order, AutoLISP to be present, or any databases to be open. Calls involving any of these assumptions will result in an error condition, sometimes fatal. AcDb and AcGi libraries are generally not yet active, although related AcRx and other structures are in place.

kUnloadAppMsg

Do perform final system resource cleanup. Anything started or created in kInitAppMsg should now be stopped or destroyed. 

Don't expect things to be any different from the description of kInitAppMsg. AutoCAD could be mostly dismantled by the time this call is made, except for the libraries listed as active in the kInitAppMsg Do description.

kOleUnloadAppMsg

This message should be responded to only by applications using ActiveX Automation.

Do respond with AcRx::kRetOK, if the application can be unloaded (none of its ActiveX objects or interfaces are being referenced by other applications). If it cannot be unloaded, respond with AcRx::kRetError.

kLoadDwgMsg

Do perform initialization relevant to the current drawing edit session. AcDb, AcGi, and the user interface API are all now active. Whether anything has been done to the drawing is not specified. All AutoCAD-supplied APIs are now active. You can perform AutoLISP function registration at this time, and initialize the user interface. Other operations to perform now include polling AutoCAD drivers and querying AcEditorReactor events if you want the earliest possible access to

acdbHostApplicationServices()->workingDatabase(). 

Don't do anything you would not want to happen for every drawing edit session. Assume this message is sent more than once per program execution.

kUnloadDwgMsg

Do release or clean up everything started or registered in response to kLoadDwgMsg code. Release all AcDb reactors, excluding persistent reactors. 

Don't release system resources that are not tied to an edit session, or clean up AcRx classes, AcEd reactors, or commands; they remain valid across edit sessions.

kDependencyMsg

Do perform any actions that are necessary for your application when other applications become dependent on it, such as locking your application so that it cannot be unloaded.

kNoDependencyMsg

Do perform any actions that are necessary for your application when there are no longer any other applications dependent on yours, such as unlocking your application so that it can be unloaded by the user if desired.

kInvkSubrMsg

Do invoke the functions registered with acedDefun(). Determine the function by making a call to acedGetFuncode(). Return values with acedRetxxx(). 

Don't do much here except function invocation.

kPreQuitMsg

Do unload any dependencies (applications, DLLs, and so on) that your application controls to ensure that they are unloaded before your application.

kEndMsg

kCfgMsg

kQuitMsg

kSaveMsg

Do consider using the AcEditorReactor event callbacks as an alternative to responding to these messages. 

Don't respond to these messages if you're responding to the equivalent event callbacks made through AcEditorReactor.