#pragma once // CDlgRange 对话框 #include #include #include #define INIT_VAL_API_PROTO std::function class CDlgRange : public CDialogEx { DECLARE_DYNAMIC(CDlgRange) INIT_VAL_API_PROTO init_val_api_; std::function < std::wstring(const wchar_t*/*name*/, int/*index*/)> item_val_; std::function item_all_; std::wstring name_; std::wstring get_item_text(UINT id); public: CDlgRange(const wchar_t* name, int type, CWnd* pParent = nullptr); // 标准构造函数 virtual ~CDlgRange(); // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_RANGE }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() public: typedef struct _cond_val { std::wstring val; std::wstring cond; // for range, must lead by 'min:' or 'max:' or 'step:' struct _cond_val() : val(L""), cond(L"") {} struct _cond_val(const std::wstring& v) : val(v), cond(L"") {} }CONDVAL; std::vector vals_; std::vector init_; int list_cur_sel_; std::vector visible_; enum {TYPE_RANGE, TYPE_LIST, TYPE_FIELDS, TYPE_VISIBLE}; int type_; // 0 - range; 1 - list; 2 - modify fields void set_init_val_api(INIT_VAL_API_PROTO api, std::function get_opts, std::function < std::wstring(const wchar_t*/*name*/, int/*index*/)> range) { init_val_api_ = api; item_val_ = range; item_all_ = get_opts; } void set_visible_values(const std::vector& vals) { visible_ = vals; } afx_msg void OnBnClickedButton1(); CListCtrl list_; afx_msg void OnBnClickedOk(); afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult); CComboBox val_; CComboBox range_type_; CMenu func_menu_; afx_msg void OnCbnSelchangeComboField(); afx_msg void OnRangevaluemenuDefault(); afx_msg void OnRangevaluemenuDelete(); afx_msg void OnRangevaluemenuSetcondition(); afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult); };