LAPTOP-SNT8I5JK\Boounion
2025-10-10 8cd1ad310c5e559435ff38e518b8fad89852b55f
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// ServoGraph.h: interface for the CServoGraph class.
//
//////////////////////////////////////////////////////////////////////
 
#if !defined(AFX_SERVOGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)
#define AFX_vGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_
 
 
#pragma comment(lib, "Msimg32.lib")            // TransparentBlt
#include <vector>
 
 
 
//====== ServoGraph =====================================================
 
#ifndef NOSERVOGRAPH
 
#ifdef _WIN32
 
#define BYSERVOGRAPH_CLASSA       "BYServoGraph"
#define BYSERVOGRAPH_CLASSW       L"BYServoGraph"
 
#ifdef UNICODE
#define  BYSERVOGRAPH_CLASS       BYSERVOGRAPH_CLASSW
#else
#define  BYSERVOGRAPH_CLASS       BYSERVOGRAPH_CLASSA
#endif
 
#else
#define BYSERVOGRAPH_CLASS        "BYSERVOGraph"
#endif
 
 
#define BYSTAG_SERVOGRAPH         _T("ISSERVOGRAPH")
 
 
//====== WM_NOTIFY codes (NMHDR.code values) ==================================
#define BYSERVOGRAPH_FIRST                 (0U-1390U)       //
#define BYSERVOGRAPH_LAST                 (0U-1350U)
#define BYSERVOGRAPH_ITEM_CLICKED          (BYSERVOGRAPH_FIRST - 1)
 
 
typedef struct tagBYSERVOGRAPH_NMHDR
{
    NMHDR        nmhdr;
    DWORD        dwData;
    DWORD        dwData1;
    DWORD        dwData2;
} BYSERVOGRAPH_NMHDR;
 
#endif
 
 
 
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
 
#define HMGRAPH_HITCODETEST            _T("HitCode")
#define HMGRAPH_HT_NOWHERE            0x1
#define HMGRAPH_HT_ITEM                0x2
 
 
class CServoGraph
{
private:
    typedef struct tagIMAGE
    {
        int id;
        char szPath[MAX_PATH];
        int x;
        int y;
        HBITMAP hBitmap;
        int bmWidth;
        int bmHeight;
        float angle;
    } IMAGE;
 
 
    class INDICATEBOX
    {
    public:
        INDICATEBOX() {
            this->id = 0;
            this->x = 0;
            this->y = 0;
            this->box1Width = 0;
            this->box1BackgroundColor = RGB(255, 255, 255);
            this->box1FrameColor[0] = RGB(22, 22, 22);
            this->box1FrameColor[1] = RGB(22, 22, 22);
            this->box2Width = 0;
            this->box2BackgroundColor = RGB(0, 255, 255);;
            this->box2FrameColor = RGB(255, 255, 0);;
            this->bBox2Visible = FALSE;
            this->m_pData = nullptr;
        };
        ~INDICATEBOX() {};
 
    public:
        int id;
        int x;
        int y;
        int box1Width;
        COLORREF box1BackgroundColor;
        COLORREF box1FrameColor[2];
        char szText[64];
        int box2Width;
        COLORREF box2BackgroundColor;
        COLORREF box2FrameColor;
        BOOL bBox2Visible;
        std::vector<void*> m_contexts;
        void* m_pData;
    };
 
    class INDICATEBKGND
    {
    public:
        INDICATEBKGND() {
            this->id = 0;
            this->rect = { 0, 0, 10, 10 };
            this->backgroundColor = RGB(255, 255, 255);;
        };
        ~INDICATEBKGND() {};
 
    public:
        int id;
        RECT rect;
        COLORREF backgroundColor;
    };
 
public:
    CServoGraph();
    virtual ~CServoGraph();
    static BOOL RegisterWndClass();
    static CServoGraph* Hook(HWND hWnd);
    void Notify(int nCode, int dwData, int dwData1 = 0, int dwData2 = 0);
    void Release();
    void SetBkgndColor(COLORREF cr);
    static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    static LRESULT OnNcCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
    LRESULT OnDestroy(WPARAM wParam, LPARAM lParam);
    LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
    LRESULT OnPaint(WPARAM wParam, LPARAM lParam);
    LRESULT OnMouseMove(WPARAM wParam, LPARAM lParam);
    LRESULT OnSize(WPARAM wParam, LPARAM lParam);
    LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
 
public:
    void Invalidata();
    void AddImage(int id, char* pszPath, int x, int y);
    void AddIndicateBox(int id, int x, int y, int width);
    void AddIndicateBox(int id, int x, int y, int width,
        COLORREF crFrame1, COLORREF crFrame2, COLORREF crBackground);
    void AddIndicateBoxContext(int id, void* pContext);
    BOOL RemoveIndicateBoxContext(int id, void* pContext);
    BOOL RemoveIndicateBoxAllContext(int id);
    const std::vector<void*>& GetIndicateBoxContexts(int id);
    bool IsIndicateBoxContextsEmpty(int id);
    void SetIndicateBoxData(int id, void* pData);
    void* GetIndicateBoxData(int id);
    void ShowIndicateBoxInterior(int id, COLORREF color);
    void HideIndicateBoxInterior(int id);
    CServoGraph::INDICATEBOX* GetIndicateBox(int id);
    void AddIndicateBkgnd(int id, int left, int top, int width, int height, COLORREF color);
    void SetIndicateBkgndColor(int id, COLORREF color);
    CServoGraph::INDICATEBKGND* GetIndicateBkgnd(int id);
    void SetResDir(CString strDir);
    CServoGraph::IMAGE* GetImage(int id);
    int HitTest(POINT pt, OUT void*& pItem);
    void GetIndicateBoxRect(INDICATEBOX* pBox, LPRECT lprcBox);
    BOOL GetIndicateBoxRect(int id, LPRECT lprcBox);
    void SetBoxText(int id, const char* pszText, const char* pszTooltip);
    HWND GetSafeWnd();
    void UpdateImageCoordinates(int id, int newX, int newY);
    void UpdateIndicateBoxCoordinates(int id, int newX, int newY);
    void UpdateImageAngle(int id, float angle);
    void UpdateIndicateBox1Colors(int id, COLORREF newBackgroundColor, COLORREF newFrameColor1, COLORREF newFrameColor2);
    void UpdateIndicateBox2Colors(int id, COLORREF newBackgroundColor, COLORREF newFrameColor);
 
private:
    void DrawImage(HDC hMemDC, IMAGE& item);
 
private:
    HWND        m_hWnd;
    COLORREF m_crBkgnd;
    CString m_strResDir;
 
private:
    std::vector<IMAGE> m_images;
    std::vector<INDICATEBOX> m_indicateBoxs;
    std::vector<INDICATEBKGND> m_indicateBkgnds;
    void* m_pHighItem;
    HWND m_hWndTooltip;
};
 
#endif // !defined(AFX_EQUIPMENTGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)