123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #include "stdafx.h"
- #include "GetIntTool.h"
- #include "ToolDialog.h"
- #include "Resource.h"
- DLL_TOOL_DESC m_Description;
- ///////////////////////////////////////////////////////////////////
- // 返回工具新实例的指针
- extern "C" __declspec(dllexport) CDllTool<int,float>* GetToolPtr(CWnd * pWnd)
- {
- CGetIntTool * p = NULL;
- p = new CGetIntTool( pWnd);
- return p;
- }
- ////////////////////////////////////////////////////////////////
- // 生成工具描述
- extern "C" __declspec(dllexport) const DLL_TOOL_DESC& Description()
- {
- // 生成dll描述
- m_Description.strCategory = _T("变量生成");
- m_Description.strName = _T("Get_Int");
- m_Description.strVersion = _T("1.0");
- m_Description.strInfo = _T("This Info");
- // 接口
- m_Description.Interfaces.clear();
- DLL_INF_DESC inf;
- inf.strName = _T("Int.OutPut");
- inf.nIndex = 1;
- inf.bWay = INF_OUT;
- inf.strValueType = PARAM_INT;
- inf.bIsDisp = true;
- m_Description.Interfaces.push_back(inf);
- inf.strName = _T("float.OutPut");
- inf.nIndex = 2;
- inf.bWay = INF_OUT;
- inf.strValueType = PARAM_float;
- inf.bIsDisp = true;
- m_Description.Interfaces.push_back(inf);
- return m_Description;
- }
- CGetIntTool::CGetIntTool(CWnd * pWnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // 重新生成描述
- Description();
- // 赋初值
- m_Value1 = PARAM_INT_DEFAULT_VALUE;
- pDlg = NULL;
- pDlg = new CToolDialog();
- pDlg->Create(IDD_GETINT_DIALOG, CWnd::FromHandle(pWnd->GetSafeHwnd()));
- pDlg->ShowWindow(SW_HIDE);
- if (pDlg != NULL)
- {
- m_Even.hEvenHandle = NULL;
- m_Even = pDlg->GetEvent();
- }
- }
- CGetIntTool::~CGetIntTool()
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (pDlg != NULL)
- {
- pDlg->DestroyWindow();
- delete pDlg;
- pDlg = NULL;
- }
- if (m_Even.hEvenHandle != NULL)
- {
- CloseHandle(m_Even.hEvenHandle);
- m_Even.hEvenHandle = NULL;
- }
- }
- ////////////////////////////////////////////////////////////////////
- // 主框架的信息传入dll
- void CGetIntTool::MainFrameInfo(FRAMEINFO* info)
- {
-
- if (pDlg != NULL)
- {
- pDlg->pFrameInfo = info;
- }
- }
- //系统Run和Stop时调用
- void CGetIntTool::Running(bool bRun)
- {
- if (pDlg != NULL)
- {
- pDlg->Running(bRun);
- }
- }
- // 序列化
- void CGetIntTool::Serialize(CArchive& ar)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (pDlg != NULL)
- {
- pDlg->Serialize(ar);
- }
- }
- // 显示参数设置对话框
- void CGetIntTool::ShowDialog(CString strName)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (pDlg != NULL)
- {
- pDlg->SetWindowTextW(strName);
- pDlg->BringWindowToTop();
- pDlg->ShowWindow(SW_SHOW);
- }
- }
- int CGetIntTool::Execute()
- {
- // ForTest输出执行的结果信息
- int nStatus = 0;
- if (pDlg != NULL)
- {
- nStatus = pDlg->Execute();
- m_Value1 = pDlg->m_Value;
- m_Value2 = pDlg->m_Value2;
- }
- // CString strTip;
- // strTip.Format(_T("Tool - %s\nInterface - %s\nExecute output:%d\n"),
- // m_Description.strName, m_Description.Interfaces[0].strName, m_Value1);
- // AfxMessageBox(strTip, MB_ICONINFORMATION);
- return nStatus;
- }
|