GetIntTool.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #include "stdafx.h"
  2. #include "GetIntTool.h"
  3. #include "ToolDialog.h"
  4. #include "Resource.h"
  5. DLL_TOOL_DESC m_Description;
  6. ///////////////////////////////////////////////////////////////////
  7. // 返回工具新实例的指针
  8. extern "C" __declspec(dllexport) CDllTool<int,float>* GetToolPtr(CWnd * pWnd)
  9. {
  10. CGetIntTool * p = NULL;
  11. p = new CGetIntTool( pWnd);
  12. return p;
  13. }
  14. ////////////////////////////////////////////////////////////////
  15. // 生成工具描述
  16. extern "C" __declspec(dllexport) const DLL_TOOL_DESC& Description()
  17. {
  18. // 生成dll描述
  19. m_Description.strCategory = _T("变量生成");
  20. m_Description.strName = _T("Get_Int");
  21. m_Description.strVersion = _T("1.0");
  22. m_Description.strInfo = _T("This Info");
  23. // 接口
  24. m_Description.Interfaces.clear();
  25. DLL_INF_DESC inf;
  26. inf.strName = _T("Int.OutPut");
  27. inf.nIndex = 1;
  28. inf.bWay = INF_OUT;
  29. inf.strValueType = PARAM_INT;
  30. inf.bIsDisp = true;
  31. m_Description.Interfaces.push_back(inf);
  32. inf.strName = _T("float.OutPut");
  33. inf.nIndex = 2;
  34. inf.bWay = INF_OUT;
  35. inf.strValueType = PARAM_float;
  36. inf.bIsDisp = true;
  37. m_Description.Interfaces.push_back(inf);
  38. return m_Description;
  39. }
  40. CGetIntTool::CGetIntTool(CWnd * pWnd)
  41. {
  42. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  43. // 重新生成描述
  44. Description();
  45. // 赋初值
  46. m_Value1 = PARAM_INT_DEFAULT_VALUE;
  47. pDlg = NULL;
  48. pDlg = new CToolDialog();
  49. pDlg->Create(IDD_GETINT_DIALOG, CWnd::FromHandle(pWnd->GetSafeHwnd()));
  50. pDlg->ShowWindow(SW_HIDE);
  51. if (pDlg != NULL)
  52. {
  53. m_Even.hEvenHandle = NULL;
  54. m_Even = pDlg->GetEvent();
  55. }
  56. }
  57. CGetIntTool::~CGetIntTool()
  58. {
  59. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  60. if (pDlg != NULL)
  61. {
  62. pDlg->DestroyWindow();
  63. delete pDlg;
  64. pDlg = NULL;
  65. }
  66. if (m_Even.hEvenHandle != NULL)
  67. {
  68. CloseHandle(m_Even.hEvenHandle);
  69. m_Even.hEvenHandle = NULL;
  70. }
  71. }
  72. ////////////////////////////////////////////////////////////////////
  73. // 主框架的信息传入dll
  74. void CGetIntTool::MainFrameInfo(FRAMEINFO* info)
  75. {
  76. if (pDlg != NULL)
  77. {
  78. pDlg->pFrameInfo = info;
  79. }
  80. }
  81. //系统Run和Stop时调用
  82. void CGetIntTool::Running(bool bRun)
  83. {
  84. if (pDlg != NULL)
  85. {
  86. pDlg->Running(bRun);
  87. }
  88. }
  89. // 序列化
  90. void CGetIntTool::Serialize(CArchive& ar)
  91. {
  92. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  93. if (pDlg != NULL)
  94. {
  95. pDlg->Serialize(ar);
  96. }
  97. }
  98. // 显示参数设置对话框
  99. void CGetIntTool::ShowDialog(CString strName)
  100. {
  101. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  102. if (pDlg != NULL)
  103. {
  104. pDlg->SetWindowTextW(strName);
  105. pDlg->BringWindowToTop();
  106. pDlg->ShowWindow(SW_SHOW);
  107. }
  108. }
  109. int CGetIntTool::Execute()
  110. {
  111. // ForTest输出执行的结果信息
  112. int nStatus = 0;
  113. if (pDlg != NULL)
  114. {
  115. nStatus = pDlg->Execute();
  116. m_Value1 = pDlg->m_Value;
  117. m_Value2 = pDlg->m_Value2;
  118. }
  119. // CString strTip;
  120. // strTip.Format(_T("Tool - %s\nInterface - %s\nExecute output:%d\n"),
  121. // m_Description.strName, m_Description.Interfaces[0].strName, m_Value1);
  122. // AfxMessageBox(strTip, MB_ICONINFORMATION);
  123. return nStatus;
  124. }