㈠ 如何設置ug編程中的後處理
在設置UG編程中的後處理時,首先需創建ObjectARX的DLL程序。打開項目選項,選擇「MFC AppWizard(DLL)",選擇MFC Extension DLL,輸入項目名。在「Project Settings"對話框中,於「General"標簽項的「Microsoft Foundation Classes "域選擇「Use MFC in a Shared DLL ."。打開由AppWizard生成的.cpp項目文件,移除AFX_EXTENSION_MODULE宏,並添加AC_IMPLEMENT_EXTENSION_MODULE(emx)宏。Emx提供預設資源和模塊資源,切換資源狀態。刪除不必要的代碼,添加所需代碼。
在Link標簽項中,「General"欄「Output file name"項輸入編譯後的應用程序名,後綴為.arx。「Output"欄,「Base address"項輸入「0x1c000000","Entry-point symbol"項輸入「DllEntryPoint@12"。在C/C++標簽項中,「Code Generation"欄「Use Run-time library"項選「Multithread DLL"。在「Preprocessor"欄中定義_WINDLL,_AFXDLL。
MFC模塊狀態執行和資源處理對於ARX程序至關重要。每個使用了MFC的模塊(EXE,DLL)都存在一種「全局」數據,MFC正是通過這種全局數據才能執行正確的操作。在ARX程序中加入AC_IMPLEMENT_EXTENSION_MODULE(emx)宏,可以由emx.AttachInstance切換模塊資源,由emx.DetachInstance()恢復預設資源。
ARX的框架代碼示例如下:
#include "stdafx.h"
#include "AsdkAcUiSample.h"
#include "AsdkAcUiDialogSample.h"
#include "AcExtensionMole.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern "C" HWND adsw_acadMainWnd();
AC_IMPLEMENT_EXTENSION_MODULE(theArxDLL);
static void initApp()
{
CAcMoleResourceOverride resOverride;
}
static void unloadApp()
{
}
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
theArxDLL.AttachInstance(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
theArxDLL.DetachInstance();
}
return 1; // ok
}
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(appId);
acrxDynamicLinker->registerAppMDIAware(appId);
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
case AcRx::kInitDialogMsg:
break;
default:
break;
}
return AcRx::kRetOK;
}
遵循以上步驟,就可以在UG編程中成功設置後處理。應用向導在ObjectARX 2000 SDK中可用於生成ARX程序框架代碼,為編程提供便利。