Browse Source

学习项目06_cdrPDF2Clip分离按钮功能到单独cpp文件,添加 Makefile 用来编译

蘭雅sRGB 8 months ago
parent
commit
c210d61a6e

BIN
04_ToolsBox/Makefile


BIN
05_ToolsBox_CreateDialog/Makefile


BIN
06_cdrPDF2Clip/Makefile


+ 255 - 0
06_cdrPDF2Clip/ToolsBox.cpp

@@ -0,0 +1,255 @@
+#include <stdio.h>
+#include <windows.h>
+#include "resource.h"
+#include "cdrapp.h"
+
+static HINSTANCE g_hResource = NULL;
+
+BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    if (fdwReason == DLL_PROCESS_ATTACH) {
+        g_hResource = (HINSTANCE)hinstDLL;
+    }
+    return TRUE;
+}
+
+class ToolsBoxPlugin : public VGCore::IVGAppPlugin
+{
+private:
+
+    volatile ULONG m_ulRefCount;
+    long m_lCookie;
+
+    static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+    void OpenToolsBox();
+
+
+public:
+    ToolsBoxPlugin();
+    VGCore::IVGApplication* m_pApp;
+
+// IUnknown
+public:
+    STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
+    STDMETHOD_(ULONG, AddRef)(void) { return ++m_ulRefCount; }
+    STDMETHOD_(ULONG, Release)(void)
+    {
+        ULONG ulCount = --m_ulRefCount;
+        if (ulCount == 0) {
+            delete this;
+        }
+        return ulCount;
+    }
+
+// IDispatch
+public:
+    STDMETHOD(GetTypeInfoCount)(UINT* pctinfo) { return E_NOTIMPL; }
+    STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) { return E_NOTIMPL; }
+    STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) { return E_NOTIMPL; }
+    STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
+
+// IVGAppPlugin
+public:
+    STDMETHOD(raw_OnLoad)(VGCore::IVGApplication* Application);
+    STDMETHOD(raw_StartSession)();
+    STDMETHOD(raw_StopSession)();
+    STDMETHOD(raw_OnUnload)();
+
+};
+
+ToolsBoxPlugin::ToolsBoxPlugin()
+{
+    m_pApp = NULL;
+    m_lCookie = 0;
+    m_ulRefCount = 1;
+}
+
+STDMETHODIMP ToolsBoxPlugin::QueryInterface(REFIID riid, void** ppvObject)
+{
+    HRESULT hr = S_OK;
+    m_ulRefCount++;
+    if (riid == IID_IUnknown) {
+        *ppvObject = (IUnknown*)this;
+    } else if (riid == IID_IDispatch) {
+        *ppvObject = (IDispatch*)this;
+    } else if (riid == __uuidof(VGCore::IVGAppPlugin)) {
+        *ppvObject = (VGCore::IVGAppPlugin*)this;
+    } else {
+        m_ulRefCount--;
+        hr = E_NOINTERFACE;
+    }
+    return hr;
+}
+
+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
+        if (pDispParams != NULL && pDispParams->cArgs == 1) {
+            _bstr_t strCmd(pDispParams->rgvarg[0].bstrVal);
+            if (strCmd == _bstr_t("OpenToolsBox")) {
+                //   MessageBox(NULL, _bstr_t("OpenToolsBox"), _bstr_t("OpenToolsBox"), MB_ICONSTOP);
+                OpenToolsBox();
+            }
+        }
+        break;
+
+    case 0x0015: // DISPID_APP_ONPLUGINCMDSTATE
+        if (pDispParams != NULL && pDispParams->cArgs == 3) {
+            _bstr_t strCmd(pDispParams->rgvarg[2].bstrVal);
+            if (strCmd == _bstr_t("OpenToolsBox")) {
+                *pDispParams->rgvarg[1].pboolVal = VARIANT_TRUE;
+            }
+        }
+        break;
+    }
+    return S_OK;
+}
+
+STDMETHODIMP ToolsBoxPlugin::raw_OnLoad(VGCore::IVGApplication* Application)
+{
+    m_pApp = Application;
+    if (m_pApp) {
+        m_pApp->AddRef();
+    }
+    return S_OK;
+}
+
+STDMETHODIMP ToolsBoxPlugin::raw_StartSession()
+{
+    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);
+        ctl->SetIcon2(_bstr_t("guid://d2fdc0d9-09f8-4948-944c-4297395c05b7"));
+        m_lCookie = m_pApp->AdviseEvents(this);
+    } catch (_com_error &e) {
+        MessageBox(NULL, e.Description(), _bstr_t("Error"), MB_ICONSTOP);
+    }
+    return S_OK;
+}
+
+STDMETHODIMP ToolsBoxPlugin::raw_StopSession()
+{
+    try {
+        m_pApp->UnadviseEvents(m_lCookie);
+        m_pApp->RemovePluginCommand(_bstr_t("OpenToolsBox"));
+    } catch (_com_error &e) {
+        MessageBox(NULL, e.Description(), _bstr_t("Error"), MB_ICONSTOP);
+    }
+    return S_OK;
+}
+
+STDMETHODIMP ToolsBoxPlugin::raw_OnUnload()
+{
+    if (m_pApp) {
+        m_pApp->Release();
+        m_pApp = NULL;
+    }
+    return S_OK;
+}
+
+void ToolsBoxPlugin::OpenToolsBox()
+{
+    m_pApp->StartupMode = VGCore::cdrStartupDoNothing;
+
+    INT_PTR nHandle = m_pApp->AppWindow->Handle;
+    HWND hAppWnd = reinterpret_cast<HWND>(nHandle);
+
+    // 创建非模态对话框
+    HWND hDlgWnd = CreateDialogParam(g_hResource, MAKEINTRESOURCE(IDD_TOOLS_BOX), hAppWnd, DlgProc, (LPARAM)m_pApp);
+    // 在创建对话框之前存储 m_pApp 指针
+    SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)m_pApp);
+
+    // 获取屏幕的宽度和高度
+    RECT rect;
+    GetWindowRect(GetDesktopWindow(), &rect);
+    int screenWidth = rect.right - rect.left;
+    int screenHeight = rect.bottom - rect.top;
+
+    // 计算对话框窗口的宽度和高度
+    RECT dlgRect;
+    GetWindowRect(hDlgWnd, &dlgRect);
+    int dlgWidth = dlgRect.right - dlgRect.left;
+    int dlgHeight = dlgRect.bottom - dlgRect.top;
+
+    // 计算对话框窗口的左上角坐标,使其居中显示
+    int x = (screenWidth - dlgWidth) / 2;
+    int y = (screenHeight - dlgHeight) / 2;
+
+    // 设置对话框窗口的位置
+    SetWindowPos(hDlgWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+    // 设置对话框窗口的父窗口  // #define GWL_HWNDPARENT      (-8)
+    SetWindowLong(hDlgWnd, -8, (LONG)hAppWnd);
+    // 显示对话框窗口
+    ShowWindow(hDlgWnd, SW_SHOW);
+}
+
+
+INT_PTR CALLBACK ToolsBoxPlugin::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    // 从附加数据中获取 m_pApp 指针
+    VGCore::IVGApplication* cdr = reinterpret_cast<VGCore::IVGApplication*>(GetWindowLongPtr(hDlg, DWLP_USER));
+
+    if (uMsg == WM_COMMAND) {
+        try {
+            switch (LOWORD(wParam)) {
+            case IDC_RED :
+                AdobeAI_Copy_ImportCdr(cdr);
+              //  fill_red(cdr);
+               MessageBox(NULL, "AdobeAI_Copy_ImportCdr", "CPG代码测试", MB_ICONSTOP);
+                break;
+
+            case IDC_CQL_OUTLINE:
+                cql_OutlineColor(cdr);
+                Active_CorelWindows(hDlg);
+                break;
+
+            case IDC_CQL_FILL:
+                cql_FillColor(cdr);
+                Active_CorelWindows(hDlg);
+                break;
+
+            case IDC_CQL_SIZE:
+                cql_SameSize(cdr);
+                Active_CorelWindows(hDlg);
+                break;
+
+            case IDC_CLEAR_FILL:
+                Clear_Fill(cdr);
+                break;
+
+            case IDC_SR_FLIP:
+                Shapes_Filp(cdr);
+                break;
+
+            case IDC_CDR2AI:
+                CdrCopy_to_AdobeAI(cdr);
+                break;
+
+            case IDC_AI2CDR:
+                AdobeAI_Copy_ImportCdr(cdr);
+                break;
+
+            case IDOK:
+            case IDCANCEL:
+                EndDialog(hDlg, 0);
+                break;
+            }
+
+        } catch (_com_error &e) {
+            MessageBox(NULL, e.Description(), "Error", MB_ICONSTOP);
+        }
+
+    } else if (uMsg == WM_INITDIALOG) {
+        return 1;
+    }
+    return 0;
+}
+
+extern "C" __declspec(dllexport) DWORD APIENTRY AttachPlugin(VGCore::IVGAppPlugin** ppIPlugin)
+{
+    *ppIPlugin = new ToolsBoxPlugin;
+    return 0x100;
+}

+ 40 - 0
06_cdrPDF2Clip/ToolsBox.rc

@@ -0,0 +1,40 @@
+// Generated by ResEdit 1.6.6
+// Copyright (C) 2006-2015
+// http://www.resedit.net
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include "resource.h"
+
+
+
+
+//
+// Bitmap resources
+//
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+IDB_BITMAP1        BITMAP         ".\\cpg.bmp"
+
+
+
+//
+// Dialog resources
+//
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+IDD_TOOLS_BOX DIALOGEX 0, 0, 136, 226
+STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
+CAPTION "Tools Box"
+FONT 8, "MS Shell Dlg", 400, 0, 1
+{
+    LTEXT           "蘭雅 CorelDRAW CPG 插件 2024.6.30 测试", 0, 18, 120, 97, 18, SS_LEFT, WS_EX_LEFT
+    CONTROL         IDB_BITMAP1, 0, WC_STATIC, SS_BITMAP, 1, 149, 133, 75, WS_EX_LEFT
+    PUSHBUTTON      "测试功能按钮", IDC_RED, 73, 3, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "CQL轮廓色相同", IDC_CQL_OUTLINE, 5, 2, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "无填色", IDC_CLEAR_FILL, 73, 30, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "批量镜像", IDC_SR_FLIP, 73, 58, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "CQL颜色相同", IDC_CQL_FILL, 5, 30, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "CQL尺寸相同", IDC_CQL_SIZE, 5, 58, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "CDR复制到AI", IDC_CDR2AI, 5, 86, 59, 24, 0, WS_EX_LEFT
+    PUSHBUTTON      "AI粘贴到CDR", IDC_AI2CDR, 73, 86, 59, 24, 0, WS_EX_LEFT
+}

+ 172 - 0
06_cdrPDF2Clip/cdrPDF2Clip.cpp

@@ -0,0 +1,172 @@
+#include "cdrapp.h"
+#include <stdio.h>
+#include <windows.h>
+
+
+#define CUSTOM_FORMAT RegisterClipboardFormatA("Portable Document Format")
+
+bool pdf_to_clipboard(const char *pdffile)
+{
+    // 打开剪贴板
+    if (!OpenClipboard(NULL)) {
+        printf("Failed to open clipboard.\n");
+        return false;
+    }
+
+    // 清空剪贴板
+    EmptyClipboard();
+
+    // 读取PDF文件到内存
+    FILE *file = fopen(pdffile, "rb");
+    if (!file) {
+        printf("Failed to open file.\n");
+        CloseClipboard();
+        return false;
+    }
+
+    // 获取文件大小
+    fseek(file, 0, SEEK_END);
+    size_t fileSize = ftell(file);
+    fseek(file, 0, SEEK_SET);
+
+    // 分配内存并读取文件内容
+    void *pdfData = malloc(fileSize);
+    if (!pdfData) {
+        printf("Failed to allocate memory.\n");
+        fclose(file);
+        CloseClipboard();
+        return false;
+    }
+
+    fread(pdfData, 1, fileSize, file);
+    fclose(file);
+
+    // 将二进制数据写入剪贴板
+    HGLOBAL hGlobal = GlobalAlloc(GHND, fileSize);
+    if (!hGlobal) {
+        printf("Failed to allocate global memory.\n");
+        free(pdfData);
+        CloseClipboard();
+        return false;
+    }
+
+    memcpy(GlobalLock(hGlobal), pdfData, fileSize);
+    GlobalUnlock(hGlobal);
+
+    if (!SetClipboardData(CUSTOM_FORMAT, hGlobal)) {
+        printf("Failed to set clipboard data.\n");
+        GlobalFree(hGlobal);
+        free(pdfData);
+        CloseClipboard();
+        return false;
+    }
+    // 关闭剪贴板
+    CloseClipboard();
+
+    printf("PDF binary data copied to clipboard using custom format.\n");
+    // 不要忘记释放内存
+    free(pdfData);
+    return true;
+}
+
+bool clipboard_to_pdf(const char *outputFile)
+{
+    // 打开剪贴板
+    if (!OpenClipboard(NULL)) {
+        printf("Failed to open clipboard.\n");
+        return false;
+    }
+
+    // 获取剪贴板中的PDF数据
+    HANDLE hData = GetClipboardData(CUSTOM_FORMAT);
+    if (!hData) {
+        printf("Failed to get clipboard data.\n");
+        CloseClipboard();
+        return false;
+    }
+
+    // 锁定内存并获取指针
+    void *pdfData = GlobalLock(hData);
+    if (!pdfData) {
+        printf("Failed to lock global memory.\n");
+        CloseClipboard();
+        return false;
+    }
+
+    // 获取PDF数据的大小
+    size_t fileSize = GlobalSize(hData);
+
+    // 将PDF数据写入文件
+    FILE *file = fopen(outputFile, "wb");
+    if (!file) {
+        printf("Failed to open output file.\n");
+        GlobalUnlock(hData);
+        CloseClipboard();
+        return false;
+    }
+
+    fwrite(pdfData, 1, fileSize, file);
+    fclose(file);
+
+    // 解锁内存并关闭剪贴板
+    GlobalUnlock(hData);
+    CloseClipboard();
+
+    printf("PDF binary data from clipboard saved to file: %s\n", outputFile);
+
+    return true;
+}
+
+bool cdr_savepdf(corel *cdr, const char *outputFile)
+{
+    DeleteFile(_bstr_t(outputFile));
+    auto pdfst = cdr->ActiveDocument->PDFSettings;
+    pdfst->BitmapCompression = pdfLZW;
+    pdfst->ColorMode = pdfCMYK;
+    pdfst->EmbedBaseFonts = cdrFalse;
+    pdfst->EmbedFonts = cdrFalse;
+    pdfst->FileInformation = cdrFalse;
+    pdfst->Hyperlinks = cdrFalse;
+    pdfst->IncludeBleed = cdrFalse;
+    pdfst->Linearize = cdrTrue;
+    pdfst->MaintainOPILinks = cdrTrue;
+    pdfst->Overprints = cdrTrue;
+    pdfst->PutpdfVersion(pdfVersion14); //'pdfVersion14 : pdfVersion13;
+    pdfst->PublishRange = pdfSelection;
+    pdfst->RegistrationMarks = cdrFalse;
+    pdfst->SpotColors = cdrTrue;
+    pdfst->Startup = pdfPageOnly;
+    pdfst->SubsetFonts = cdrFalse;
+    pdfst->TextAsCurves = cdrFalse;
+    pdfst->Thumbnails = cdrFalse;
+    cdr->ActiveDocument->PublishToPDF(_bstr_t(outputFile));
+
+    return true;
+}
+
+void CdrCopy_to_AdobeAI(corel *cdr)
+{
+    char path[MAX_PATH] = {0};
+    GetTempPath(MAX_PATH, path);
+    char *f = strcat(path, "CDR2AI.pdf");
+    if (cdr_savepdf(cdr, f))
+        pdf_to_clipboard(f);
+}
+
+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);
+   impflt->Finish();
+}
+
+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))
+        pdf_ImportCdr(cdr, f);
+}

+ 27 - 0
06_cdrPDF2Clip/cdrapi.cpp

@@ -0,0 +1,27 @@
+#include <windows.h>
+#include "cdrapi.h"
+
+void BeginOpt(corel *cdr)
+{
+  auto name = _bstr_t("Undo");
+  cdr->EventsEnabled = false;
+  cdr->ActiveDocument->BeginCommandGroup(name);
+  cdr->ActiveDocument->Unit = cdrMillimeter;
+  cdr->Optimization = true;
+}
+
+void EndOpt(corel *cdr)
+{
+  cdr->EventsEnabled = true;
+  cdr->Optimization = false;
+  cdr->EventsEnabled = true;
+  cdr->ActiveDocument->ReferencePoint = cdrBottomLeft;
+  cdr->Application->Refresh();
+  cdr->ActiveDocument->EndCommandGroup();
+}
+
+void Active_CorelWindows(HWND hDlg)
+{                
+  // 将焦点返回到父窗口 关闭对话框窗口
+  SetFocus(GetParent(hDlg));
+}

+ 17 - 0
06_cdrPDF2Clip/cdrapi.h

@@ -0,0 +1,17 @@
+#ifndef CDRAPI_H_INCLUDED
+#define CDRAPI_H_INCLUDED
+
+#import "VGCoreAuto.tlb" \
+rename("GetCommandLine", "VGGetCommandLine") \
+rename("CopyFile", "VGCore") \
+rename("FindWindow", "VGFindWindow")
+
+#define corel VGCore::IVGApplication
+using namespace VGCore;
+
+
+void BeginOpt(corel *cdr);
+void EndOpt(corel *cdr);
+void Active_CorelWindows(HWND hDlg);
+
+#endif // CDRAPI_H_INCLUDED

+ 84 - 0
06_cdrPDF2Clip/cdrapp.cpp

@@ -0,0 +1,84 @@
+#include "cdrapp.h"
+
+// sr.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0)
+bool fill_red(corel *cdr)
+{
+    auto sr = cdr->ActiveSelectionRange;
+    auto red = cdr->CreateCMYKColor(0, 100, 100, 0);
+    sr->ApplyUniformFill(red);
+
+    return true;
+}
+
+bool cql_OutlineColor(corel *cdr)
+{
+    auto col = cdr->CreateCMYKColor(0, 100, 100, 0);
+    auto s = cdr->ActiveShape;
+    col-> CopyAssign(s->Outline->Color);
+    col->ConvertToRGB();
+
+    auto r = col->RGBRed;
+    auto g = col->RGBGreen;
+    auto b = col->RGBBlue;
+
+    char buf[256] = { 0 };
+    sprintf(buf, "@Outline.Color.rgb[.r='%d' And .g='%d' And .b='%d']", r, g, b);
+    auto cql = _bstr_t(buf);
+    // MessageBox(NULL, cql, "cql 轮廓颜色", MB_ICONSTOP);
+    auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
+    sr->CreateSelection();
+    return true;
+}
+
+bool cql_FillColor(corel *cdr)
+{
+    auto col = cdr->CreateCMYKColor(0, 100, 100, 0);
+    auto s = cdr->ActiveShape;
+    col-> CopyAssign(s->Fill->UniformColor);
+    col->ConvertToRGB();
+
+    auto r = col->RGBRed;
+    auto g = col->RGBGreen;
+    auto b = col->RGBBlue;
+
+    char buf[256] = { 0 };
+    sprintf(buf, "@Fill.Color.rgb[.r='%d' And .g='%d' And .b='%d']", r, g, b);
+    auto cql = _bstr_t(buf);
+
+    auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
+    sr->CreateSelection();
+    return true;
+}
+
+bool cql_SameSize(corel *cdr)
+{
+    cdr->ActiveDocument->Unit = cdrMillimeter;
+    auto s = cdr->ActiveShape;
+
+    char buf[256] = { 0 };
+    sprintf(buf, "@width = {%lf mm} and @height = {%lf mm}", s->SizeWidth, s->SizeHeight);
+    auto cql = _bstr_t(buf);
+
+    //  MessageBox(NULL, cql, "cql 尺寸相同", MB_ICONSTOP);
+    auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
+    sr->CreateSelection();
+    return true;
+}
+
+bool Shapes_Filp(corel *cdr)
+{
+    BeginOpt(cdr);
+    auto sr = cdr->ActiveSelectionRange;
+    // CorelDRAW Shapes 物件 Item 编号从1开始
+    for (auto i = 0; i != sr->Count; i++)
+        sr->Shapes->Item[i + 1]->Flip(VGCore::cdrFlipHorizontal);
+
+    EndOpt(cdr);
+    return true;
+}
+
+bool  Clear_Fill(corel *cdr)
+{
+    cdr->ActiveSelection->Fill->ApplyNoFill();
+    return true;
+}

+ 16 - 0
06_cdrPDF2Clip/cdrapp.h

@@ -0,0 +1,16 @@
+#ifndef CDRAPP_H_INCLUDED
+#define CDRAPP_H_INCLUDED
+#include "cdrapi.h"
+
+bool fill_red(corel *cdr);
+bool cql_OutlineColor(corel *cdr);
+bool cql_FillColor(corel *cdr);
+bool cql_SameSize(corel *cdr);
+bool Shapes_Filp(corel *cdr);
+bool Shapes_Filp(corel *cdr);
+bool Clear_Fill(corel *cdr);
+
+void CdrCopy_to_AdobeAI(corel *cdr);
+void AdobeAI_Copy_ImportCdr(corel *cdr);
+
+#endif // CDRAPP_H_INCLUDED

BIN
06_cdrPDF2Clip/cpg.bmp


+ 57 - 0
06_cdrPDF2Clip/lycpg64.cbp

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="lycpg64" />
+		<Option pch_mode="2" />
+		<Option compiler="microsoft_visual_c_2022" />
+		<Build>
+			<Target title="Debug">
+				<Option output="bin/Debug/lycpg64" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Debug/" />
+				<Option type="3" />
+				<Option compiler="microsoft_visual_c_2022" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="/Zi" />
+					<Add option="/D_DEBUG" />
+				</Compiler>
+				<Linker>
+					<Add option="/debug" />
+				</Linker>
+			</Target>
+			<Target title="Release">
+				<Option output="bin/Release/lycpg64" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release/" />
+				<Option type="3" />
+				<Option compiler="microsoft_visual_c_2022" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="/Ox" />
+					<Add option="/DNDEBUG" />
+					<Add directory="../TypeLibs" />
+				</Compiler>
+			</Target>
+		</Build>
+		<Compiler>
+			<Add option="/W3" />
+			<Add option="/EHsc" />
+		</Compiler>
+		<Unit filename="ToolsBox.cpp" />
+		<Unit filename="ToolsBox.rc">
+			<Option compilerVar="WINDRES" />
+			<Option target="Release" />
+		</Unit>
+		<Unit filename="cdrPDF2Clip.cpp" />
+		<Unit filename="cdrapi.cpp" />
+		<Unit filename="cdrapi.h" />
+		<Unit filename="cdrapp.cpp" />
+		<Unit filename="cdrapp.h" />
+		<Unit filename="resource.h" />
+		<Extensions>
+			<lib_finder disable_auto="1" />
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>

+ 14 - 0
06_cdrPDF2Clip/resource.h

@@ -0,0 +1,14 @@
+#ifndef IDC_STATIC
+#define IDC_STATIC (-1)
+#endif
+
+#define IDD_TOOLS_BOX                           100
+#define IDB_BITMAP1                             101
+#define IDC_RED                                 40000
+#define IDC_CQL_FILL                            40001
+#define IDC_CQL_OUTLINE                         40002
+#define IDC_CQL_SIZE                            40003
+#define IDC_SR_FLIP                             40004
+#define IDC_CLEAR_FILL                          40005
+#define IDC_CDR2AI                              40006
+#define IDC_AI2CDR                              40007

+ 9 - 0
README.md

@@ -89,3 +89,12 @@ auto cql = _bstr_t(buf);
 auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
 auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
 sr->CreateSelection();
 sr->CreateSelection();
 ```
 ```
+
+## 学习项目 `06_cdrPDF2Clip` 分离按钮功能到单独cpp文件 `cdrPDF2Clip.cpp` 和 `cdrapp.cpp`,添加 `Makefile` 用来编译
+
+### 使用 `Makefile` 用来编译,[参考视频](https://www.bilibili.com/video/BV1Nx4y1874F)
+```shell
+nmake
+name install
+nmake clean
+```