本文参考以下博文并完善了代码实现:https://www.cnblogs.com/shankun/p/To_use_AutoCAD_internal_Dialog.html
常用的几个对话框对应的函数为:
1、尺寸标注样式编辑对话框:
int acedEditDimstyleInteractie(AcDbDatabase *,AcDbDimStyleTableRecord *,int);
2、多行文字编辑对话框:
int acedEditMTextInteractie(AcDbMText *);
3、公差编辑对话框:
void acedEditToleranceInteractie(AcDbFcf *);
4、CAD自己的文件对话框:
int acedGetFileD(const char *,const char *,const char *,int,struct resbuf *);
int acedGetFileNavDialog(const char ,const char ,const char ,const char ,int,struct resbuf);
5、填充面板对话框:
extern bool acedHatchPalletteDialog(const char Pattern, bool bAllowCustom, char& result);
6、线形对话框:
bool acedLinetypeDialog(AcDbObjectId,bool,char * &,AcDbObjectId &);
7、线宽对话框:
bool acedLineWeightDialog(AcDb::LineWeight,bool,AcDb::LineWeight &);
8、打印样式对话框:
bool acedPlotstyleDialog(const char *,bool,char * &);
9、填充编辑对话框:
void hatchedit(long,int,bool,const AcDbObject *);
10、文字样式对话框:
void inokeTextStyleDialog(AcDbDatabase *,CString *);
这些函数大多不在文档中,可按两种方式使用:
1、使用前声明函数原型,直接调用即可,注意使用前需要切换资源模块。
void ShowLineWeightDlg()
{
//声明原型
bool acedLineWeightDialog(AcDb::LineWeight, bool, AcDb::LineWeight &);
HMODULE hModule = GetModuleHandle(_T("acad.exe"));
CAcModuleResourceOverride cadResource(hModule);
AcDb::LineWeight nLWeight;
if (acedLineWeightDialog(AcDb::LineWeight::kLnWt020, true, nLWeight))
{
//... do something
acutPrintf(_T("hello"));
}
}
2、先用GetModuleHandle获取acad.exe的句柄,然后用GetProcAddress动态获取指定函数的入口地址,之后就可以直接调用了。
void ShowLineWeightDlg()
{
//声明原型
typedef bool(*DlgLineWeight)(AcDb::LineWeight, bool, AcDb::LineWeight &);
HMODULE hModule = GetModuleHandle(_T("acad.exe"));
if (hModule)
{
AcDb::LineWeight nLWeight;
CAcModuleResourceOverride cadResource(hModule);
//在C++中,会发生名称改编,
// acedLineWeightDialog名称改编为:?acedLineWeightDialog@@YA_NW4LineWeight@AcDb@@_NAEAW412@@Z
FARPROC pFunc = GetProcAddress(hModule, "?acedLineWeightDialog@@YA_NW4LineWeight@AcDb@@_NAEAW412@@Z");
DlgLineWeight pFunLWeight = (DlgLineWeight)pFunc;
if (pFunLWeight)
{
if (pFunLWeight(AcDb::LineWeight::kLnWt025, true, nLWeight))
{
//... do something
acutPrintf(_T("hello"));
}
}
}
}
公用库报表控件类:
CReportRecordItemAcCmColor
CReportRecordItemAssocVariable
CReportRecordItemBlock
CReportRecordItemBool
CReportRecordItemCellAlignment
CReportRecordItemLinetype
CReportRecordItemLineWeight
CReportRecordItemNumber
CReportRecordItemPropertyString
CReportRecordItemSymbol