IRControlWnd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
  2. // (“Fluent UI”)。该示例仅供参考,
  3. // 用以补充《Microsoft 基础类参考》和
  4. // MFC C++ 库软件随附的相关电子文档。
  5. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
  6. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问
  7. // https://go.microsoft.com/fwlink/?LinkId=238214.
  8. //
  9. // 版权所有(C) Microsoft Corporation
  10. // 保留所有权利。
  11. #include "DlgIRControl.h"
  12. #include <map>
  13. #pragma once
  14. // 按钮id起始值;
  15. #define BTNID 11000
  16. // layout.xml item;
  17. typedef struct __BTN_INFO__
  18. {
  19. std::string name;
  20. int width;
  21. int height;
  22. DWORD color;
  23. CMFCButton *pBTN;
  24. bool bEnable = false;
  25. }BtnInfo, *pBtnInfo;
  26. class CIRControlToolBar : public CMFCToolBar
  27. {
  28. public:
  29. virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler)
  30. {
  31. CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler);
  32. }
  33. virtual BOOL AllowShowOnList() const { return FALSE; }
  34. };
  35. class CIRControlWnd : public CDockablePane
  36. {
  37. // 构造
  38. public:
  39. CIRControlWnd() noexcept;
  40. void AdjustLayout();
  41. // 特性
  42. public:
  43. protected:
  44. CFont m_fntPropList;
  45. // 重启服务端进程;
  46. CMFCButton m_btnRestart;
  47. // 信号集文件;
  48. CComboBox m_wndSignalCombo;
  49. // 选择通用遥控器;
  50. CMFCButton m_wndSignalCheck;
  51. #if __PANE_DLG__
  52. CDlgIRControl m_dlgIRControl;
  53. #endif
  54. // 实现
  55. public:
  56. virtual ~CIRControlWnd();
  57. // 去掉关闭按钮;但组合多个pane时无效;
  58. virtual BOOL CanBeClosed() const { return FALSE; };
  59. // 禁止拖动Pane;
  60. virtual BOOL FloatPane(CRect rectFloat, AFX_DOCK_METHOD dockMethod = DM_UNKNOWN, bool bShow = true) { return FALSE; }
  61. // 禁用停靠,双击底部无效(不会停靠)
  62. virtual BOOL CanFloat() const { return FALSE; };
  63. // 禁用大小;//崩溃;
  64. //virtual BOOL IsResizable() const {return FALSE;}
  65. protected:
  66. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  67. afx_msg void OnSize(UINT nType, int cx, int cy);
  68. afx_msg void OnExpandAllProperties();
  69. afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI);
  70. afx_msg void OnSortProperties();
  71. afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI);
  72. afx_msg void OnProperties1();
  73. afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI);
  74. afx_msg void OnProperties2();
  75. afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI);
  76. afx_msg void OnSetFocus(CWnd* pOldWnd);
  77. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  78. // 下拉框选项变化事件;
  79. afx_msg void OnCbnSelchangeSignal();
  80. DECLARE_MESSAGE_MAP()
  81. void SetPropListFont();
  82. int m_nComboHeight;
  83. // 重启红老鼠;
  84. void StartIRDevice(BOOL bReStart = TRUE);
  85. // 重载信号文件;
  86. void ReLoadSignalXml();
  87. // 禁用信号按钮;
  88. void DisableSignalBtn() {
  89. for (std::vector<BtnInfo>::iterator it = m_vtBtnInfo.begin(); it != m_vtBtnInfo.end(); it++)
  90. {
  91. it->bEnable = false;
  92. }
  93. }
  94. public:
  95. std::map<UINT, BtnInfo&> m_map_btn;
  96. std::vector<std::string> m_vtsignal_gen;
  97. std::vector<std::string> m_vtsignal_pro;
  98. void LoadSignals();
  99. std::vector<BtnInfo> m_vtBtnInfo;
  100. void Loadlayout(std::vector<BtnInfo> &vt);
  101. afx_msg void OnPaint();
  102. // 单击按钮;
  103. afx_msg void OnSignalBtnClick(UINT uId);
  104. // 更新按钮状态;
  105. afx_msg void OnUpdateSignalBtn(CCmdUI* pCmdUI);
  106. // 更新checkbox状态;
  107. afx_msg void OnUpdateCheckBox(CCmdUI * pCmdUI);
  108. afx_msg void OnCheckBoxClicked();
  109. // 更新重启按钮状态;
  110. afx_msg void OnUpdateBtnRestartProc(CCmdUI* pCmdUI);
  111. afx_msg void OnBtnRestartProcClicked();
  112. // 更新按钮实际状态;
  113. void UpdateSignalBtnStatus();
  114. };