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