{"id":291,"date":"2021-03-15T19:44:41","date_gmt":"2021-03-15T11:44:41","guid":{"rendered":"http:\/\/liyanliang.net\/?p=291"},"modified":"2021-03-15T19:46:08","modified_gmt":"2021-03-15T11:46:08","slug":"callafunctioninanotherproject","status":"publish","type":"post","link":"http:\/\/liyanliang.net\/index.php\/2021\/03\/15\/callafunctioninanotherproject\/","title":{"rendered":"\u8c03\u7528\u53e6\u5916\u4e00\u4e2a\u9879\u76ee\u4e2d\u7684\u51fd\u6570-\u8bbe\u8ba1\u6a21\u5f0f\u89e3\u8026"},"content":{"rendered":"\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u80cc\u666f\u63cf\u8ff0<\/p>\n\n\n\n<p>\u73b0\u9700\u8981\u5728\u9879\u76ee CDP_cmd \u4e2d\u8c03\u7528\u9879\u76ee CDP_dgnCalc \u7c7bCAnalRstHelper_JTGTJ212011\u4e2d\u7684\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BOOL GetElemValuePositiveOrNegativeMy(IN OUT TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue, BOOL bPositive);<\/pre>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u89e3\u51b3\u65b9\u6cd5<\/p>\n\n\n\n<p><strong>1.\u67e5\u770b\u9879\u76ee\u5c5e\u6027\uff0c\u53d1\u73b0\u9879\u76eeCDP_cmd\u548c\u9879\u76eeCDP_dgnCalc\u5747\u5f15\u7528\u9879\u76eeCDP_db\uff0c\u6545\u53ef\u5728CDP_db\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7eaf\u865a\u57fa\u7c7b(\u63a5\u53e3)\u3002<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/liyanliangpublic.oss-cn-hongkong.aliyuncs.com\/img\/20210315191248.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/liyanliangpublic.oss-cn-hongkong.aliyuncs.com\/img\/20210315191313.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>IAnalRstHelper_JTGTJ212011.h<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#pragma once\nclass CNSDocBase;\nstruct TElemPosition;\nclass CAnalRstHelper_JTGTJ212011;\n\u200b\n#include \"HeaderPre.h\"\nclass __MY_EXT_CLASS__ IAnalRstHelper_JTGTJ212011\n{\npublic:\n    IAnalRstHelper_JTGTJ212011(void);\n    virtual ~IAnalRstHelper_JTGTJ212011(void);\n    static CAnalRstHelper_JTGTJ212011* GetInstance();\n    static void SetInstance(CAnalRstHelper_JTGTJ212011* pSingleton);  \/\/ \u591a\u6001\n    static void DeleteInstance();\nprotected:\n    static CAnalRstHelper_JTGTJ212011* m_pSingleton;  \/\/ \u5355\u4f8b\n\u200b\npublic:\n    \/\/ \u4e0b\u9762\u8fd93\u4e2a\u51fd\u6570\u662f\u6211\u4eec\u9700\u8981\u5728\u53e6\u5916\u4e00\u4e2a\u6a21\u5757\u4e2d\u8c03\u7528\u7684\u51fd\u6570,\u628a\u5b83\u4eec\u8bbe\u4e3a\u9700\u63a5\u53e3\n    virtual BOOL GetElemValuePositiveOrNegativeMy(IN OUT TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue, BOOL bPositive) = 0;\n    virtual BOOL GetElemValueMymax(IN const TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue) = 0;\n    virtual BOOL GetElemValueAbsFzmax(IN const TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue, OUT BOOL bMax) = 0;\n};\n#include \"HeaderPost.h\"<\/pre>\n\n\n\n<p>IAnalRstHelper_JTGTJ212011.cpp<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"stdafx.h\"\n#include \"IAnalRstHelper_JTGTJ212011.h\"\n\u200b\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\u200b\nclass CAnalRstHelper_JTGTJ212011;\n\u200b\nCAnalRstHelper_JTGTJ212011* IAnalRstHelper_JTGTJ212011::m_pSingleton = nullptr;\n\u200b\nIAnalRstHelper_JTGTJ212011::IAnalRstHelper_JTGTJ212011()\n{\n\u200b\n}\n\u200b\nIAnalRstHelper_JTGTJ212011::~IAnalRstHelper_JTGTJ212011(void)\n{\n\u200b\n}\n\u200b\nCAnalRstHelper_JTGTJ212011* IAnalRstHelper_JTGTJ212011::GetInstance()\n{\n    return m_pSingleton;\n}\n\u200b\nvoid IAnalRstHelper_JTGTJ212011::SetInstance(CAnalRstHelper_JTGTJ212011* pSingleton)\n{\n    m_pSingleton = pSingleton;\n}\n\u200b\nvoid IAnalRstHelper_JTGTJ212011::DeleteInstance()\n{\n    if (m_pSingleton)\n    {\n        delete m_pSingleton;\n        m_pSingleton = nullptr;\n    }\n}<\/pre>\n\n\n\n<p><strong>2.\u4f7f\u5b50\u7c7bCAnalRstHelper_JTGTJ212011\u7ee7\u627f\u4e8e\u865a\u57fa\u7c7bIAnalRstHelper_JTGTJ212011<\/strong><\/p>\n\n\n\n<p>CAnalRstHelper_JTGTJ212011.h<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#pragma once\n#include \"..\/CDP_db\/IAnalRstHelper_JTGTJ212011.h\"\n\u200b\n#include \"HeaderPre.h\"\nclass __MY_EXT_CLASS__ CAnalRstHelper_JTGTJ212011 : public IAnalRstHelper_JTGTJ212011\n{\npublic:\n    CAnalRstHelper_JTGTJ212011();\n    CAnalRstHelper_JTGTJ212011();\n    virtual ~CAnalRstHelper_JTGTJ212011(void);\n\u200b\npublic:\n    virtual BOOL GetElemValueMymax(IN const TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue);\n    virtual BOOL GetElemValuePositiveOrNegativeMy(IN OUT TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue, BOOL bPositive);\n    virtual BOOL GetElemValueAbsFzmax(IN const TElemPosition&amp; tElemPos,OUT double&amp; dCtrlValue, OUT BOOL bMax);\n};\n\u200b\n#include \"HeaderPost.h\"<\/pre>\n\n\n\n<p>CAnalRstHelper_JTGTJ212011.cpp<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u5168\u5c40\u51fd\u6570,\u521d\u59cb\u5316\u5b9e\u4f8b\nvoid initDgnHelper()\n{   \n    \/\/ \u591a\u6001\n    IAnalRstHelper_JTGTJ212011::SetInstance(new CAnalRstHelper_JTGTJ212011());\n}\n\u200b\nvoid uninitDgnHelper()\n{   \n    IAnalRstHelper_JTGTJ212011::DeleteInstance();\n}<\/pre>\n\n\n\n<p><strong>3.\u5728\u6a21\u5757CDP_dgnCalc\u7684dllmain.cpp\u4e2d\u521d\u59cb\u5316\u5b9e\u4f8b\u548c\u6790\u6784\u5b9e\u4f8b\u5185\u5b58<\/strong><\/p>\n\n\n\n<p>dllmain.cpp<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"stdafx.h\"\n#include \"dllmain.h\"\n#include &lt;afxwin.h>\n#include &lt;afxdllx.h>\n\u200b\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#endif\n\u200b\n\/\/ \u58f0\u660e\u4e3a\u5916\u90e8\u51fd\u6570\nextern void initDgnHelper();  \nextern void uninitDgnHelper();\n\u200b\nextern \"C\" int APIENTRY\nDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\n{\n\u200b\n    if (dwReason == DLL_PROCESS_ATTACH)\n    {\n        initDgnHelper(); \/\/ \u521d\u59cb\u5316\u5b9e\u4f8b\n    }\n    else if (dwReason == DLL_PROCESS_DETACH)\n    {\n        uninitDgnHelper(); \/\/ \u6790\u6784\u5b9e\u4f8b\n    }\n    return 1;   \/\/ \u72ac\u7262\n}\n\u200b<\/pre>\n\n\n\n<p><strong>4.\u4f7f\u7528\uff1a\u5728\u6a21\u5757CDP_cmd\u7684CMCtseDlg.cpp\u4e2d\u8c03\u7528\u51fd\u6570<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BOOL CCMCtseDlg::GetMaxPositiveOrMinNegativeMy(const TArraySpanInfo&amp; taSpanInfo, OUT TElemPosition&amp; ElemPos, BOOL bPositive) const\n{\n    ElemPos = curElemPos;\n    double dNextElemMy = 0.0;\n\u200b\n    \/\/ \u83b7\u53d6\u5b9e\u4f8b\n    CAnalRstHelper_JTGTJ212011* pAnalRstHelper = IAnalRstHelper_JTGTJ212011::GetInstance(); \n    \n    \/\/ \u8c03\u7528\u5b9e\u4f8bCAnalRstHelper_JTGTJ212011\u4e2d\u7684\u51fd\u6570\n    if (!pAnalRstHelper->GetElemValuePositiveOrNegativeMy(nextElemPos, dNextElemMy, bPositive))\n    {\n        ASSERT(0);\n    }\n    \n    return TRUE;\n}<\/pre>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\">\u603b\u7ed3\uff1a<\/p>\n\n\n\n<p>\u672c\u65b9\u6cd5\u4e3b\u8981\u5229\u7528C++\u7684\u591a\u6001\u7279\u6027\uff0c\u5728\u865a\u63a5\u53e3\u7c7b\u4e2dIAnalRstHelper_JTGTJ212011new\u4e00\u4e2aCAnalRstHelper_JTGTJ212011\u7684\u5b9e\u4f8b\uff0c\u5728\u4f7f\u7528\u65f6\u867d\u7136\u7528\u7684\u662f\u63a5\u53e3\u7c7b\u6307\u9488\uff0c\u4f46\u5b9e\u9645\u4e0a\u5176\u8c03\u7528\u7684\u662f\u5b50\u7c7bCAnalRstHelper_JTGTJ212011\u7684\u51fd\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f\u63cf\u8ff0 \u73b0\u9700\u8981\u5728\u9879\u76ee CDP_cmd \u4e2d\u8c03\u7528\u9879\u76ee CDP_dgnCalc \u7c7bCAnalRstHelper_JTGTJ212011\u4e2d\u7684\u51fd\u6570\uff1a \u89e3\u51b3\u65b9\u6cd5 1.\u67e5\u770b\u9879\u76ee\u5c5e\u6027\uff0c\u53d1\u73b0\u9879\u76eeCDP_cmd\u548c\u9879\u76eeCDP_dgnCalc\u5747\u5f15\u7528\u9879\u76eeCDP_db\uff0c\u6545\u53ef\u5728CDP_db\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7eaf\u865a\u57fa\u7c7b(\u63a5\u53e3)\u3002 IAnalRstHelper_JTGTJ212011.h IAnalRstHelper_JTGTJ212011.cpp 2.\u4f7f\u5b50\u7c7bCAnalRstHelper_JTGTJ212011\u7ee7\u627f\u4e8e\u865a\u57fa\u7c7bIAnalRstHelper_JTGTJ212011 CAnalRstHelper_JTGTJ212011.h CAnalRstHelper_JTGTJ212011.cpp 3.\u5728\u6a21\u5757CDP_dgnCalc\u7684dllmain.cpp\u4e2d\u521d\u59cb\u5316\u5b9e\u4f8b\u548c\u6790\u6784\u5b9e\u4f8b\u5185\u5b58 dllmain.cpp 4.\u4f7f\u7528\uff1a\u5728\u6a21\u5757CDP_cmd\u7684CMCtseDlg.cpp\u4e2d\u8c03\u7528\u51fd\u6570 \u603b\u7ed3\uff1a \u672c\u65b9\u6cd5\u4e3b\u8981\u5229\u7528C++\u7684\u591a\u6001\u7279\u6027\uff0c\u5728\u865a\u63a5\u53e3\u7c7b\u4e2dIAnalRstHelper_JTGTJ212011new\u4e00\u4e2aCAnalRstHelper_JTGTJ2120&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/liyanliang.net\/index.php\/2021\/03\/15\/callafunctioninanotherproject\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":1,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":292,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions\/292"}],"wp:attachment":[{"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/liyanliang.net\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}