IRControlWnd.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #define WM_IR_SHOT_IMG WM_USER + 10012
  17. // layout.xml item;
  18. typedef struct __BTN_INFO__
  19. {
  20. std::string name;
  21. int width;
  22. int height;
  23. DWORD color;
  24. CMFCButton *pBTN;
  25. bool bEnable = false;
  26. }BtnInfo, *pBtnInfo;
  27. class CIRControlToolBar : public CMFCToolBar
  28. {
  29. public:
  30. virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler)
  31. {
  32. CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler);
  33. }
  34. virtual BOOL AllowShowOnList() const { return FALSE; }
  35. };
  36. class CIRControlWnd : public CDockablePane
  37. {
  38. // 构造
  39. public:
  40. CIRControlWnd() noexcept;
  41. void AdjustLayout();
  42. // 特性
  43. public:
  44. protected:
  45. CFont m_fntPropList;
  46. // 重启服务端进程;
  47. CMFCButton m_btnRestart;
  48. // 信号集文件;
  49. CComboBox m_wndSignalCombo;
  50. // 选择通用遥控器;
  51. CMFCButton m_wndSignalCheck;
  52. #if __PANE_DLG__
  53. CDlgIRControl m_dlgIRControl;
  54. #endif
  55. // 实现
  56. public:
  57. virtual ~CIRControlWnd();
  58. // 去掉关闭按钮;但组合多个pane时无效;
  59. virtual BOOL CanBeClosed() const { return FALSE; };
  60. // 禁止拖动Pane;
  61. virtual BOOL FloatPane(CRect rectFloat, AFX_DOCK_METHOD dockMethod = DM_UNKNOWN, bool bShow = true) { return FALSE; }
  62. // 禁用停靠,双击底部无效(不会停靠)
  63. virtual BOOL CanFloat() const { return FALSE; };
  64. // 禁用大小;//崩溃;
  65. //virtual BOOL IsResizable() const {return FALSE;}
  66. protected:
  67. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  68. afx_msg void OnSize(UINT nType, int cx, int cy);
  69. afx_msg void OnExpandAllProperties();
  70. afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI);
  71. afx_msg void OnSortProperties();
  72. afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI);
  73. afx_msg void OnProperties1();
  74. afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI);
  75. afx_msg void OnProperties2();
  76. afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI);
  77. afx_msg void OnSetFocus(CWnd* pOldWnd);
  78. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  79. // 下拉框选项变化事件;
  80. afx_msg void OnCbnSelchangeSignal();
  81. DECLARE_MESSAGE_MAP()
  82. void SetPropListFont();
  83. int m_nComboHeight;
  84. // 重启红老鼠;
  85. void StartIRDevice(BOOL bReStart = TRUE);
  86. // 重载信号文件;
  87. void ReLoadSignalXml();
  88. // 禁用信号按钮;
  89. void DisableSignalBtn() {
  90. for (std::vector<BtnInfo>::iterator it = m_vtBtnInfo.begin(); it != m_vtBtnInfo.end(); it++)
  91. {
  92. it->bEnable = false;
  93. }
  94. }
  95. public:
  96. std::map<UINT, BtnInfo&> m_map_btn;
  97. std::vector<std::string> m_vtsignal_gen;
  98. std::vector<std::string> m_vtsignal_pro;
  99. void LoadSignals();
  100. std::vector<BtnInfo> m_vtBtnInfo;
  101. void Loadlayout(std::vector<BtnInfo> &vt);
  102. afx_msg void OnPaint();
  103. // 单击按钮;
  104. afx_msg void OnSignalBtnClick(UINT uId);
  105. // 更新按钮状态;
  106. afx_msg void OnUpdateSignalBtn(CCmdUI* pCmdUI);
  107. // 更新checkbox状态;
  108. afx_msg void OnUpdateCheckBox(CCmdUI * pCmdUI);
  109. afx_msg void OnCheckBoxClicked();
  110. // 更新重启按钮状态;
  111. afx_msg void OnUpdateBtnRestartProc(CCmdUI* pCmdUI);
  112. afx_msg void OnBtnRestartProcClicked();
  113. // 更新按钮实际状态;
  114. void UpdateSignalBtnStatus();
  115. // 自动根据Combobox选项长度设置宽度;
  116. void AutoSetDroppedWidth();
  117. // CCombobox添加水平滚动条;
  118. void AddHScroll();
  119. // 遥控截图自定义消息;
  120. BOOL m_bSendKey;
  121. afx_msg LRESULT OnIRShotImg(WPARAM wparam, LPARAM lparam);
  122. };