📄 inspector.cpp
字号:
// Inspector.cpp : Initialization functions
#include "StdAfx.h"
#include "StdArx.h"
#include "resource.h"
#include <afxdllx.h>
#include "AcDialogBar.h"
#include "InspectorBar.h"
#include "rEditorReactor.h"
#include "rDatabaseReactor.h"
// This command registers an ARX command.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal = -1);
HINSTANCE _hdllInstance =NULL ;
HINSTANCE hBitmapRes =NULL ;
CInspectorBar *pInspTree =NULL ;
//InspMindDataList *pDwgList =NULL ;
AsdkEdReact *edReactor =NULL ;
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_MSG
void InitApplication();
void UnloadApplication();
//}}AFX_ARX_MSG
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_ADDIN_FUNCS
//}}AFX_ARX_ADDIN_FUNCS
////////////////////////////////////////////////////////////////////////////
//
// Define the sole extension module object.
AC_IMPLEMENT_EXTENSION_MODULE(InspectorDLL);
// Now you can use the CAcModuleRecourceOverride class in
// your application to switch to the correct resource instance.
// Please see the ObjectARX Documentation for more details
//-----------------------------------------------------------------------------
//----- String functions
#ifdef _UNICODE
char buffer [256] ;
char *UnicodeToAnsi (CString st) {
*buffer ='\0' ;
WideCharToMultiByte (CP_ACP, WC_DEFAULTCHAR, st, -1, buffer, 255, NULL, NULL) ;
return (buffer) ;
}
#endif
CString GetString (UINT nID) {
CString st ;
HINSTANCE hOrg =AfxGetResourceHandle () ;
AfxSetResourceHandle (_hdllInstance) ;
st.LoadString (nID) ;
AfxSetResourceHandle (hOrg) ;
return (st) ;
}
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_hdllInstance =hInstance ;
// Extension DLL one time initialization
InspectorDLL.AttachInstance(hInstance);
InitAcUiDLL();
} else if (dwReason == DLL_PROCESS_DETACH) {
// Terminate the library before destructors are called
InspectorDLL.DetachInstance();
}
return TRUE; // ok
}
/////////////////////////////////////////////////////////////////////////////
// ObjectARX EntryPoint
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg) {
case AcRx::kInitAppMsg:
// Comment out the following line if your
// application should be locked into memory
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
InitApplication();
break;
case AcRx::kUnloadAppMsg:
UnloadApplication();
break;
}
return AcRx::kRetOK;
}
// Init this application. Register your
// commands, reactors...
void InitApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_INIT
//}}AFX_ARX_INIT
//----- Trap AutoCAD icons to be displayed in our Tree Control
char result [512] ;
ads_findfile (/*NOXLATE*/"acadbtn.dll", result) ;
if ( (hBitmapRes =::LoadLibrary (CString (result))) == NULL )
//----- We do continue and use the local resource file
hBitmapRes =_hdllInstance ;
//----- Create the Inspector Tree Dialog Bar
AfxSetResourceHandle (_hdllInstance) ;
pInspTree =new CInspectorBar ;
// pInspTree->m_bAutoDelete =TRUE ;
pInspTree->Create (
acedGetAcadFrame (), IDD_INSPECTOR,
WS_CHILD | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT | CBRS_SIZE_DYNAMIC,
AFX_IDW_CONTROLBAR_FIRST + 32 + 1
) ;
AfxSetResourceHandle (acedGetAcadResourceInstance ()) ;
pInspTree->EnableDocking (CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT) ;
acedGetAcadFrame ()->FloatControlBar (pInspTree, CPoint (100, 100), CBRS_ALIGN_TOP) ;
acedGetAcadFrame ()->ShowControlBar (pInspTree, TRUE, TRUE) ;
pInspTree->GetParent ()->SetWindowText (GetString (IDS_TITLE)) ;
//----- Add an Editor Reactor to AutoCAD to be informed of all new DWG loaded
edReactor =new AsdkEdReact (true) ; //----- Auto Initiate
//acedEditor->addReactor (edReactor) ;
//----- Scan for already loaded databases
AcApDocumentIterator *pIter =acDocManager->newAcApDocumentIterator () ;
for ( ; !pIter->done () ; ) {
pInspTree->Scan (pIter->document ()->database ()) ;
new AsdkDbReact (true, pIter->document ()) ;
pIter->step () ;
}
delete pIter ;
}
// Unload this application. Unregister all objects
// registered in InitApplication.
void UnloadApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_EXIT
//}}AFX_ARX_EXIT
//----- Close the Inspector Tree Dialog Bar
if ( pInspTree != NULL && pInspTree->GetSafeHwnd () != NULL )
pInspTree->DestroyWindow () ;
//delete pInspTree ; //----- This object is Auto Delete
//----- Remove the Editor reactor
//acedEditor->removeReactor (edReactor) ; //----- Auto release
delete edReactor ;
//----- Release AutoCAD icon library
::FreeLibrary (hBitmapRes) ;
}
// This functions registers an ARX command.
// It can be used to read the localized command name
// from a string table stored in the resources.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal)
{
char cmdLocRes[65];
// If idLocal is not -1, it's treated as an ID for
// a string stored in the resources.
if (idLocal != -1) {
HMODULE hModule = GetModuleHandle("AsdkInspector.arx");
// Load strings from the string table and register the command.
::LoadString(hModule, idLocal, cmdLocRes, 64);
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes, cmdFlags, cmdProc);
} else
// idLocal is -1, so the 'hard coded'
// localized function name is used.
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLoc, cmdFlags, cmdProc);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -