Browse Source

剪贴板保存PDF增加延时代码, INT_PTR 改成 intptr_t

Hongwenjun 6 months ago
parent
commit
1ac80c2c05

+ 8 - 1
06_cdrPDF2Clip/cdrPDF2Clip.cpp

@@ -1,6 +1,9 @@
 #include "cdrapp.h"
 #include <stdio.h>
 #include <windows.h>
+#include <thread>
+#include <chrono>
+
 
 
 #define CUSTOM_FORMAT RegisterClipboardFormatA("Portable Document Format")
@@ -167,6 +170,10 @@ void AdobeAI_Copy_ImportCdr(corel *cdr)
     char path[MAX_PATH] = {0};
     GetTempPath(MAX_PATH, path);
     char *f = strcat(path, "CDR2AI.pdf");
-    if (clipboard_to_pdf(f))
+    if (clipboard_to_pdf(f)){
+        // 延时 0.3 秒
+        std::this_thread::sleep_for(std::chrono::milliseconds(300));
         pdf_ImportCdr(cdr, f);
+    }
+
 }

+ 8 - 1
07_VBA_CallCPG/cdrPDF2Clip.cpp

@@ -1,6 +1,9 @@
 #include "cdrapp.h"
 #include <stdio.h>
 #include <windows.h>
+#include <thread>
+#include <chrono>
+
 
 
 #define CUSTOM_FORMAT RegisterClipboardFormatA("Portable Document Format")
@@ -167,6 +170,10 @@ void AdobeAI_Copy_ImportCdr(corel *cdr)
     char path[MAX_PATH] = {0};
     GetTempPath(MAX_PATH, path);
     char *f = strcat(path, "CDR2AI.pdf");
-    if (clipboard_to_pdf(f))
+    if (clipboard_to_pdf(f)){
+        // 延时 0.3 秒
+        std::this_thread::sleep_for(std::chrono::milliseconds(300));
         pdf_ImportCdr(cdr, f);
+    }
+
 }

+ 3 - 3
08_SmartGroup/ToolsBox.cpp

@@ -22,7 +22,7 @@ private:
     volatile ULONG m_ulRefCount;
     long m_lCookie;
 
-    static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+    static intptr_t CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
     void OpenToolsBox();
 
 
@@ -159,7 +159,7 @@ void ToolsBoxPlugin::OpenToolsBox()
 {
     m_pApp->StartupMode = VGCore::cdrStartupDoNothing;
 
-    INT_PTR nHandle = m_pApp->AppWindow->Handle;
+    intptr_t nHandle = m_pApp->AppWindow->Handle;
     HWND hAppWnd = reinterpret_cast<HWND>(nHandle);
 
     // 创建非模态对话框
@@ -192,7 +192,7 @@ void ToolsBoxPlugin::OpenToolsBox()
 }
 
 
-INT_PTR 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));

+ 8 - 1
08_SmartGroup/cdrPDF2Clip.cpp

@@ -1,6 +1,9 @@
 #include "cdrapp.h"
 #include <stdio.h>
 #include <windows.h>
+#include <thread>
+#include <chrono>
+
 
 
 #define CUSTOM_FORMAT RegisterClipboardFormatA("Portable Document Format")
@@ -167,6 +170,10 @@ void AdobeAI_Copy_ImportCdr(corel *cdr)
     char path[MAX_PATH] = {0};
     GetTempPath(MAX_PATH, path);
     char *f = strcat(path, "CDR2AI.pdf");
-    if (clipboard_to_pdf(f))
+    if (clipboard_to_pdf(f)){
+        // 延时 0.3 秒
+        std::this_thread::sleep_for(std::chrono::milliseconds(300));
         pdf_ImportCdr(cdr, f);
+    }
+
 }