Przeglądaj źródła

更新修复bug

蘭雅sRGB 2 miesięcy temu
rodzic
commit
1dbb8a87cc

+ 15 - 14
06_cdrPDF2Clip/cdrPDF2Clip.cpp

@@ -12,7 +12,7 @@ bool pdf_to_clipboard(const char *pdffile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
@@ -22,7 +22,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 读取PDF文件到内存
     FILE *file = fopen(pdffile, "rb");
     if (!file) {
-        printf("Failed to open file.\n");
+        // printf("Failed to open file.\n");
         CloseClipboard();
         return false;
     }
@@ -35,7 +35,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 分配内存并读取文件内容
     void *pdfData = malloc(fileSize);
     if (!pdfData) {
-        printf("Failed to allocate memory.\n");
+        // printf("Failed to allocate memory.\n");
         fclose(file);
         CloseClipboard();
         return false;
@@ -47,7 +47,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 将二进制数据写入剪贴板
     HGLOBAL hGlobal = GlobalAlloc(GHND, fileSize);
     if (!hGlobal) {
-        printf("Failed to allocate global memory.\n");
+        // printf("Failed to allocate global memory.\n");
         free(pdfData);
         CloseClipboard();
         return false;
@@ -57,7 +57,7 @@ bool pdf_to_clipboard(const char *pdffile)
     GlobalUnlock(hGlobal);
 
     if (!SetClipboardData(CUSTOM_FORMAT, hGlobal)) {
-        printf("Failed to set clipboard data.\n");
+        // printf("Failed to set clipboard data.\n");
         GlobalFree(hGlobal);
         free(pdfData);
         CloseClipboard();
@@ -66,7 +66,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 关闭剪贴板
     CloseClipboard();
 
-    printf("PDF binary data copied to clipboard using custom format.\n");
+    // printf("PDF binary data copied to clipboard using custom format.\n");
     // 不要忘记释放内存
     free(pdfData);
     return true;
@@ -76,14 +76,14 @@ bool clipboard_to_pdf(const char *outputFile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
     // 获取剪贴板中的PDF数据
     HANDLE hData = GetClipboardData(CUSTOM_FORMAT);
     if (!hData) {
-        printf("Failed to get clipboard data.\n");
+        // printf("Failed to get clipboard data.\n");
         CloseClipboard();
         return false;
     }
@@ -91,7 +91,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 锁定内存并获取指针
     void *pdfData = GlobalLock(hData);
     if (!pdfData) {
-        printf("Failed to lock global memory.\n");
+        // printf("Failed to lock global memory.\n");
         CloseClipboard();
         return false;
     }
@@ -102,7 +102,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 将PDF数据写入文件
     FILE *file = fopen(outputFile, "wb");
     if (!file) {
-        printf("Failed to open output file.\n");
+        // printf("Failed to open output file.\n");
         GlobalUnlock(hData);
         CloseClipboard();
         return false;
@@ -115,7 +115,7 @@ bool clipboard_to_pdf(const char *outputFile)
     GlobalUnlock(hData);
     CloseClipboard();
 
-    printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
+    // printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
 
     return true;
 }
@@ -161,8 +161,9 @@ bool pdf_ImportCdr(corel *cdr, const char *pdffile)
    auto si = cdr->CreateStructImportOptions();
    si->MaintainLayers = true;
    
-   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrAutoSense , si);
+   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrPDF , si);
    impflt->Finish();
+   return true;
 }
 
 void AdobeAI_Copy_ImportCdr(corel *cdr)
@@ -171,8 +172,8 @@ void AdobeAI_Copy_ImportCdr(corel *cdr)
     GetTempPath(MAX_PATH, path);
     char *f = strcat(path, "CDR2AI.pdf");
     if (clipboard_to_pdf(f)){
-        // 延时 0.3
-        std::this_thread::sleep_for(std::chrono::milliseconds(300));
+        // 延时 0.5
+        std::this_thread::sleep_for(std::chrono::milliseconds(500));
         pdf_ImportCdr(cdr, f);
     }
 

+ 15 - 14
07_VBA_CallCPG/cdrPDF2Clip.cpp

@@ -12,7 +12,7 @@ bool pdf_to_clipboard(const char *pdffile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
@@ -22,7 +22,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 读取PDF文件到内存
     FILE *file = fopen(pdffile, "rb");
     if (!file) {
-        printf("Failed to open file.\n");
+        // printf("Failed to open file.\n");
         CloseClipboard();
         return false;
     }
@@ -35,7 +35,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 分配内存并读取文件内容
     void *pdfData = malloc(fileSize);
     if (!pdfData) {
-        printf("Failed to allocate memory.\n");
+        // printf("Failed to allocate memory.\n");
         fclose(file);
         CloseClipboard();
         return false;
@@ -47,7 +47,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 将二进制数据写入剪贴板
     HGLOBAL hGlobal = GlobalAlloc(GHND, fileSize);
     if (!hGlobal) {
-        printf("Failed to allocate global memory.\n");
+        // printf("Failed to allocate global memory.\n");
         free(pdfData);
         CloseClipboard();
         return false;
@@ -57,7 +57,7 @@ bool pdf_to_clipboard(const char *pdffile)
     GlobalUnlock(hGlobal);
 
     if (!SetClipboardData(CUSTOM_FORMAT, hGlobal)) {
-        printf("Failed to set clipboard data.\n");
+        // printf("Failed to set clipboard data.\n");
         GlobalFree(hGlobal);
         free(pdfData);
         CloseClipboard();
@@ -66,7 +66,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 关闭剪贴板
     CloseClipboard();
 
-    printf("PDF binary data copied to clipboard using custom format.\n");
+    // printf("PDF binary data copied to clipboard using custom format.\n");
     // 不要忘记释放内存
     free(pdfData);
     return true;
@@ -76,14 +76,14 @@ bool clipboard_to_pdf(const char *outputFile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
     // 获取剪贴板中的PDF数据
     HANDLE hData = GetClipboardData(CUSTOM_FORMAT);
     if (!hData) {
-        printf("Failed to get clipboard data.\n");
+        // printf("Failed to get clipboard data.\n");
         CloseClipboard();
         return false;
     }
@@ -91,7 +91,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 锁定内存并获取指针
     void *pdfData = GlobalLock(hData);
     if (!pdfData) {
-        printf("Failed to lock global memory.\n");
+        // printf("Failed to lock global memory.\n");
         CloseClipboard();
         return false;
     }
@@ -102,7 +102,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 将PDF数据写入文件
     FILE *file = fopen(outputFile, "wb");
     if (!file) {
-        printf("Failed to open output file.\n");
+        // printf("Failed to open output file.\n");
         GlobalUnlock(hData);
         CloseClipboard();
         return false;
@@ -115,7 +115,7 @@ bool clipboard_to_pdf(const char *outputFile)
     GlobalUnlock(hData);
     CloseClipboard();
 
-    printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
+    // printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
 
     return true;
 }
@@ -161,8 +161,9 @@ bool pdf_ImportCdr(corel *cdr, const char *pdffile)
    auto si = cdr->CreateStructImportOptions();
    si->MaintainLayers = true;
    
-   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrAutoSense , si);
+   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrPDF , si);
    impflt->Finish();
+   return true;
 }
 
 void AdobeAI_Copy_ImportCdr(corel *cdr)
@@ -171,8 +172,8 @@ void AdobeAI_Copy_ImportCdr(corel *cdr)
     GetTempPath(MAX_PATH, path);
     char *f = strcat(path, "CDR2AI.pdf");
     if (clipboard_to_pdf(f)){
-        // 延时 0.3
-        std::this_thread::sleep_for(std::chrono::milliseconds(300));
+        // 延时 0.5
+        std::this_thread::sleep_for(std::chrono::milliseconds(500));
         pdf_ImportCdr(cdr, f);
     }
 

+ 12 - 12
08_SmartGroup/cdrPDF2Clip.cpp

@@ -12,7 +12,7 @@ bool pdf_to_clipboard(const char *pdffile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
@@ -22,7 +22,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 读取PDF文件到内存
     FILE *file = fopen(pdffile, "rb");
     if (!file) {
-        printf("Failed to open file.\n");
+        // printf("Failed to open file.\n");
         CloseClipboard();
         return false;
     }
@@ -35,7 +35,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 分配内存并读取文件内容
     void *pdfData = malloc(fileSize);
     if (!pdfData) {
-        printf("Failed to allocate memory.\n");
+        // printf("Failed to allocate memory.\n");
         fclose(file);
         CloseClipboard();
         return false;
@@ -47,7 +47,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 将二进制数据写入剪贴板
     HGLOBAL hGlobal = GlobalAlloc(GHND, fileSize);
     if (!hGlobal) {
-        printf("Failed to allocate global memory.\n");
+        // printf("Failed to allocate global memory.\n");
         free(pdfData);
         CloseClipboard();
         return false;
@@ -57,7 +57,7 @@ bool pdf_to_clipboard(const char *pdffile)
     GlobalUnlock(hGlobal);
 
     if (!SetClipboardData(CUSTOM_FORMAT, hGlobal)) {
-        printf("Failed to set clipboard data.\n");
+        // printf("Failed to set clipboard data.\n");
         GlobalFree(hGlobal);
         free(pdfData);
         CloseClipboard();
@@ -66,7 +66,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 关闭剪贴板
     CloseClipboard();
 
-    printf("PDF binary data copied to clipboard using custom format.\n");
+    // printf("PDF binary data copied to clipboard using custom format.\n");
     // 不要忘记释放内存
     free(pdfData);
     return true;
@@ -76,14 +76,14 @@ bool clipboard_to_pdf(const char *outputFile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
     // 获取剪贴板中的PDF数据
     HANDLE hData = GetClipboardData(CUSTOM_FORMAT);
     if (!hData) {
-        printf("Failed to get clipboard data.\n");
+        // printf("Failed to get clipboard data.\n");
         CloseClipboard();
         return false;
     }
@@ -91,7 +91,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 锁定内存并获取指针
     void *pdfData = GlobalLock(hData);
     if (!pdfData) {
-        printf("Failed to lock global memory.\n");
+        // printf("Failed to lock global memory.\n");
         CloseClipboard();
         return false;
     }
@@ -102,7 +102,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 将PDF数据写入文件
     FILE *file = fopen(outputFile, "wb");
     if (!file) {
-        printf("Failed to open output file.\n");
+        // printf("Failed to open output file.\n");
         GlobalUnlock(hData);
         CloseClipboard();
         return false;
@@ -115,7 +115,7 @@ bool clipboard_to_pdf(const char *outputFile)
     GlobalUnlock(hData);
     CloseClipboard();
 
-    printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
+    // printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
 
     return true;
 }
@@ -161,7 +161,7 @@ bool pdf_ImportCdr(corel *cdr, const char *pdffile)
    auto si = cdr->CreateStructImportOptions();
    si->MaintainLayers = true;
    
-   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrAutoSense , si);
+   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrPDF , si);
    impflt->Finish();
    return true;
 }

+ 12 - 13
09_BoundaryGroup/BoundaryGroup.cpp

@@ -12,9 +12,12 @@ bool isDPCurve(IVGShapePtr s) {
 IVGShapePtr CreateBoundary(corel *cdr, IVGShapePtr s) {
   IVGShapePtr scp;
   if (cdr->VersionMajor < 17) {
-    s->CreateSelection();
-    cdr->FrameWork->Automation->InvokeItem( _bstr_t("b0491566-5ffe-450a-b17e-f2f496b4eb22"));
-    scp = cdr->ActiveSelectionRange->Shapes->Item[1];
+    // s->CreateSelection();
+    // cdr->FrameWork->Automation->InvokeItem( _bstr_t("b0491566-5ffe-450a-b17e-f2f496b4eb22"));
+    // scp = cdr->ActiveSelectionRange->Shapes->Item[1];
+    BoundingBox box;
+    s->GET_BOUNDING_BOX(box);
+    scp = cdr->ActiveLayer->CreateRectangle2(box.x, box.y, box.w, box.h, ZERO_4PC);
   } else {
     //  这个 API X7 以上才支持,所以现在直接画矩形
     scp = s->CreateBoundary(0, 0, true, false);    
@@ -22,11 +25,9 @@ IVGShapePtr CreateBoundary(corel *cdr, IVGShapePtr s) {
   return scp;
 }
 
-// VGCore::IVGShapePtr VGCore::IVGShape::CreateBoundary ( double x, double y,
-// VARIANT_BOOL PlaceOnTop, VARIANT_BOOL DeleteSource ); VGCore::IVGShapePtr
-// VGCore::IVGShapeRange::CreateBoundary ( double x, double y, VARIANT_BOOL
-// PlaceOnTop, VARIANT_BOOL DeleteSource ); VARIANT_BOOL
-// VGCore::IVGCurve::IntersectsWith ( struct IVGCurve * Curve )
+// VGCore::IVGShapePtr VGCore::IVGShape::CreateBoundary ( double x, double y, VARIANT_BOOL PlaceOnTop, VARIANT_BOOL DeleteSource ); VGCore::IVGShapePtr
+// VGCore::IVGShapeRange::CreateBoundary ( double x, double y, VARIANT_BOOL PlaceOnTop, VARIANT_BOOL DeleteSource );
+// VARIANT_BOOL VGCore::IVGCurve::IntersectsWith ( struct IVGCurve * Curve )
 bool isIntWith(corel *cdr, IVGShape *s1, IVGShape *s2) {
   bool isIn = false;
   if (isDPCurve(s1) && isDPCurve(s2)) {
@@ -58,9 +59,8 @@ void calculate_center(const BoundingBox &box, double &cx, double &cy) {
   cy = box.y + (box.h / 2);
 }
 
-// VGCore::cdrPositionOfPointOverShape VGCore::IVGShape::IsOnShape ( double x,
-// double y, double HotArea ); VGCore::cdrPositionOfPointOverShape
-// VGCore::IVGCurve::IsOnCurve ( double x, double y, double HotArea );
+// VGCore::cdrPositionOfPointOverShape VGCore::IVGShape::IsOnShape ( double x, double y, double HotArea );
+// VGCore::cdrPositionOfPointOverShape VGCore::IVGCurve::IsOnCurve ( double x, double y, double HotArea );
 
 bool BoundaryGroup(corel *cdr, IVGShapeRange *sr, IVGShapeRange *srs) {
 
@@ -204,7 +204,6 @@ void run_BoundaryGroup(corel *cdr) {
   std::chrono::duration<double> duration = end - start;
   runtime = duration.count();
 
-  sprintf(infobuf, "选择物件: %d 个进行异形群组\n群组: %d 组, 时间: %.2f秒",
-          cnt, srs->Count, runtime);
+  sprintf(infobuf, "选择物件: %d 个进行异形群组\n群组: %d 组, 时间: %.2f秒", cnt, srs->Count, runtime);
   EndOpt(cdr);
 }

+ 15 - 35
09_BoundaryGroup/ToolsBox.cpp

@@ -20,14 +20,12 @@ class ToolsBoxPlugin : public VGCore::IVGAppPlugin {
 private:
   volatile ULONG m_ulRefCount;
   long m_lCookie;
-
-  static intptr_t CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
-                                   LPARAM lParam);
-  void OpenToolsBox();
+  static intptr_t CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 public:
   ToolsBoxPlugin();
   VGCore::IVGApplication *m_pApp;
+  void OpenToolsBox();
 
   // IUnknown
 public:
@@ -52,9 +50,7 @@ public:
     return E_NOTIMPL;
   }
   STDMETHOD(Invoke)
-  (DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
-   DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
-   UINT *puArgErr);
+  (DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
 
   // IVGAppPlugin
 public:
@@ -86,10 +82,7 @@ STDMETHODIMP ToolsBoxPlugin::QueryInterface(REFIID riid, void **ppvObject) {
   return hr;
 }
 
-STDMETHODIMP ToolsBoxPlugin::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
-                                    WORD wFlags, DISPPARAMS *pDispParams,
-                                    VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
-                                    UINT *puArgErr) {
+STDMETHODIMP ToolsBoxPlugin::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) {
   switch (dispIdMember) {
 
   case 0x0014: // DISPID_APP_ONPLUGINCMD
@@ -128,14 +121,9 @@ STDMETHODIMP ToolsBoxPlugin::raw_StartSession() {
   cdr = m_pApp;
 
   try {
-    m_pApp->AddPluginCommand(_bstr_t("OpenToolsBox"), _bstr_t("Tools Box"),
-                             _bstr_t("打开工具窗口"));
-
-    VGCore::ICUIControlPtr ctl =
-        m_pApp->CommandBars->Item[_bstr_t("Standard")]
-            ->Controls->AddCustomButton(VGCore::cdrCmdCategoryPlugins,
-                                        _bstr_t("OpenToolsBox"), 10,
-                                        VARIANT_FALSE);
+    m_pApp->AddPluginCommand(_bstr_t("OpenToolsBox"), _bstr_t("Tools Box"), _bstr_t("打开工具窗口"));
+
+    VGCore::ICUIControlPtr ctl = m_pApp->CommandBars->Item[_bstr_t("Standard")]->Controls->AddCustomButton(VGCore::cdrCmdCategoryPlugins, _bstr_t("OpenToolsBox"), 10, VARIANT_FALSE);
     ctl->SetIcon2(_bstr_t("guid://d2fdc0d9-09f8-4948-944c-4297395c05b7"));
     m_lCookie = m_pApp->AdviseEvents(this);
   } catch (_com_error &e) {
@@ -169,8 +157,7 @@ void ToolsBoxPlugin::OpenToolsBox() {
   HWND hAppWnd = reinterpret_cast<HWND>(nHandle);
 
   // 创建非模态对话框
-  HWND hDlgWnd = CreateDialogParam(g_hResource, MAKEINTRESOURCE(IDD_TOOLS_BOX),
-                                   hAppWnd, DlgProc, (LPARAM)m_pApp);
+  HWND hDlgWnd = CreateDialogParam(g_hResource, MAKEINTRESOURCE(IDD_TOOLS_BOX), hAppWnd, DlgProc, (LPARAM)m_pApp);
   // 在创建对话框之前存储 m_pApp 指针
   SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)m_pApp);
 
@@ -198,13 +185,11 @@ void ToolsBoxPlugin::OpenToolsBox() {
   ShowWindow(hDlgWnd, SW_SHOW);
 }
 
-// MessageBox(NULL, "更新提示信息: 激活CorelDRAW窗口", "CPG代码测试",
-// MB_ICONSTOP);
+// MessageBox(NULL, "更新提示信息: 激活CorelDRAW窗口", "CPG代码测试", MB_ICONSTOP);
 #define UPDATE_INFO_ACTIVE_CDRWND                                              \
   PutTextValue(hDlg, INFO_TEXT, infobuf);                                      \
   Active_CorelWindows(hDlg);
-intptr_t CALLBACK ToolsBoxPlugin::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
-                                          LPARAM lParam) {
+intptr_t CALLBACK ToolsBoxPlugin::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
   // 从附加数据中获取 m_pApp 指针
   VGCore::IVGApplication *cdr = reinterpret_cast<VGCore::IVGApplication *>(
       GetWindowLongPtr(hDlg, DWLP_USER));
@@ -261,21 +246,17 @@ intptr_t CALLBACK ToolsBoxPlugin::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
 
       case IDC_SR_FLIP:
         Shapes_Filp(cdr);
-        break;
+      break;
 
       case IDC_CDR2AI: {
         CdrCopy_to_AdobeAI(cdr);
-        sprintf(infobuf,
-                "把CorelDRAW软件中选择物件复制到剪贴板,请切换到AI软件粘贴");
+        sprintf(infobuf, "把CorelDRAW软件中选择物件复制到剪贴板,请切换到AI软件粘贴");
         UPDATE_INFO_ACTIVE_CDRWND
-      }
-
-      break;
+      } break;
 
       case IDC_AI2CDR: {
         AdobeAI_Copy_ImportCdr(cdr);
-        sprintf(infobuf,
-                "请先在AI软件选择物件复制,再切换到CorelDRAW软件点执行本功能");
+        sprintf(infobuf, "请先在AI软件选择物件复制,再切换到CorelDRAW软件点执行本功能");
         UPDATE_INFO_ACTIVE_CDRWND
       } break;
 
@@ -319,8 +300,7 @@ intptr_t CALLBACK ToolsBoxPlugin::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
   return 0;
 }
 
-extern "C" __declspec(dllexport) DWORD APIENTRY
-    AttachPlugin(VGCore::IVGAppPlugin **ppIPlugin) {
+extern "C" __declspec(dllexport) DWORD APIENTRY AttachPlugin(VGCore::IVGAppPlugin **ppIPlugin) {
   *ppIPlugin = new ToolsBoxPlugin;
   return 0x100;
 }

+ 7 - 3
09_BoundaryGroup/VBA_GMS/VbaCallCPG.bas

@@ -1,5 +1,9 @@
 Attribute VB_Name = "VbaCallCPG"
-Private Declare PtrSafe Function vbadll Lib "lycpg64.cpg" (ByVal code As Long, ByVal x As Double) As Long
+#If VBA7 Then
+  Private Declare PtrSafe Function vbadll Lib "lycpg64.cpg" (ByVal code As Long, ByVal x As Double) As Long
+#Else
+  Private Declare Function vbadll Lib "lycpg32.cpg" (ByVal code As Long, ByVal x As Double) As Long
+#End If
 
 Sub VBA调用CPG_CDR复制物件到AI()
  ret = vbadll(2, 0)
@@ -40,12 +44,12 @@ End Sub
 
 '// 第9号功能: 按边界批量绘制矩形  参数:正数向外,负数向内
 Sub BBox_DrawRectangle()
- ret = vbadll(9, -2#)
+ ret = vbadll(9, 0#)
 End Sub
 
 '// 第10号功能: 智能群组功能  参数:正数 向外容差  负数 向内容差
 Sub Box_AutoGroup()
- ret = vbadll(10, -2#)
+ ret = vbadll(10, 1#)
 End Sub
 
 '// 第11号功能: 异形群组功能

+ 12 - 12
09_BoundaryGroup/cdrPDF2Clip.cpp

@@ -12,7 +12,7 @@ bool pdf_to_clipboard(const char *pdffile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
@@ -22,7 +22,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 读取PDF文件到内存
     FILE *file = fopen(pdffile, "rb");
     if (!file) {
-        printf("Failed to open file.\n");
+        // printf("Failed to open file.\n");
         CloseClipboard();
         return false;
     }
@@ -35,7 +35,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 分配内存并读取文件内容
     void *pdfData = malloc(fileSize);
     if (!pdfData) {
-        printf("Failed to allocate memory.\n");
+        // printf("Failed to allocate memory.\n");
         fclose(file);
         CloseClipboard();
         return false;
@@ -47,7 +47,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 将二进制数据写入剪贴板
     HGLOBAL hGlobal = GlobalAlloc(GHND, fileSize);
     if (!hGlobal) {
-        printf("Failed to allocate global memory.\n");
+        // printf("Failed to allocate global memory.\n");
         free(pdfData);
         CloseClipboard();
         return false;
@@ -57,7 +57,7 @@ bool pdf_to_clipboard(const char *pdffile)
     GlobalUnlock(hGlobal);
 
     if (!SetClipboardData(CUSTOM_FORMAT, hGlobal)) {
-        printf("Failed to set clipboard data.\n");
+        // printf("Failed to set clipboard data.\n");
         GlobalFree(hGlobal);
         free(pdfData);
         CloseClipboard();
@@ -66,7 +66,7 @@ bool pdf_to_clipboard(const char *pdffile)
     // 关闭剪贴板
     CloseClipboard();
 
-    printf("PDF binary data copied to clipboard using custom format.\n");
+    // printf("PDF binary data copied to clipboard using custom format.\n");
     // 不要忘记释放内存
     free(pdfData);
     return true;
@@ -76,14 +76,14 @@ bool clipboard_to_pdf(const char *outputFile)
 {
     // 打开剪贴板
     if (!OpenClipboard(NULL)) {
-        printf("Failed to open clipboard.\n");
+        // printf("Failed to open clipboard.\n");
         return false;
     }
 
     // 获取剪贴板中的PDF数据
     HANDLE hData = GetClipboardData(CUSTOM_FORMAT);
     if (!hData) {
-        printf("Failed to get clipboard data.\n");
+        // printf("Failed to get clipboard data.\n");
         CloseClipboard();
         return false;
     }
@@ -91,7 +91,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 锁定内存并获取指针
     void *pdfData = GlobalLock(hData);
     if (!pdfData) {
-        printf("Failed to lock global memory.\n");
+        // printf("Failed to lock global memory.\n");
         CloseClipboard();
         return false;
     }
@@ -102,7 +102,7 @@ bool clipboard_to_pdf(const char *outputFile)
     // 将PDF数据写入文件
     FILE *file = fopen(outputFile, "wb");
     if (!file) {
-        printf("Failed to open output file.\n");
+        // printf("Failed to open output file.\n");
         GlobalUnlock(hData);
         CloseClipboard();
         return false;
@@ -115,7 +115,7 @@ bool clipboard_to_pdf(const char *outputFile)
     GlobalUnlock(hData);
     CloseClipboard();
 
-    printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
+    // printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
 
     return true;
 }
@@ -161,7 +161,7 @@ bool pdf_ImportCdr(corel *cdr, const char *pdffile)
    auto si = cdr->CreateStructImportOptions();
    si->MaintainLayers = true;
    
-   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrAutoSense , si);
+   auto impflt = cdr->ActiveLayer->ImportEx(_bstr_t(pdffile), cdrPDF , si);
    impflt->Finish();
    return true;
 }