chenluhua1980
2026-01-09 260b16a1debe7dbc33982768a37dfd48ca34b248
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
 
#define ID_MSG_VIEW_ACTIVE        WM_USER+2356
#define ID_MSG_BTN_CLICKED        WM_USER+2357
#define ID_MSG_BTN_MENU_ITEM    WM_USER+2358
 
 
class CBaseView : public CDialogEx
{
private:
    typedef struct _TOOLBTN
    {
        int id;
        HICON hIcon[4];
        char szTooltip[256];
        BOOL bEnable;
        HMENU hMenu;
    } TOOLBTN;
 
 
    DECLARE_DYNAMIC(CBaseView)
 
public:
    CBaseView(UINT id, CWnd* pPage);   // ±ê×¼¹¹Ô캯Êý
    virtual ~CBaseView();
 
 
public:
    void OnViewActive();
    void OnViewInactive();
    void AddToolBtn(int id, const char* pszIcon0Path, const char* pszIcon1Path, const char* pszIcon2Path, const char* pszIcon3Path, const char* pszTooltip);
    void SetToolBtnEnable(int id, BOOL bEnable);
    void SetToolBtnMenu(int id, HMENU hMenu);
    void Show(CWnd* pParent, LPRECT lprcBtn);
    virtual void SetContext(void* pContext);
    void* GetContext();
    virtual void OnApply();
 
private:
    int MyHitTest(POINT& point, TOOLBTN*& pBtn);
    CBaseView::TOOLBTN* GetToolBtn(int id);
    BOOL GetBtnRect(int id, LPRECT lprcBtn);
 
 
private:
    std::vector<TOOLBTN> m_toolbtns;
    TOOLBTN* m_pHotBtn;
    TOOLBTN* m_pPressBtn;
    int m_nState;
 
 
protected:
    COLORREF m_crBkgnd;
    HBRUSH m_hbrBkgnd;
    void* m_pContext;
 
 
    DECLARE_MESSAGE_MAP()
public:
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
    afx_msg void OnNcPaint();
    afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
    afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg LRESULT OnNcHitTest(CPoint point);
    afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
    afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
    afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
    virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
};