TNB Library
TnbMfcHitTest.h
[詳解]
1#pragma once
13#include "TnbMfcCommon.h"
14#include "TnbSimpleVector.h"
15
16
17
18//TNB Library
19namespace TNB {
20namespace MFC {
21
22
23
34template<typename WND = CWnd>
35class CHitTestAddinT : public WND
36{
37 DEFSUPER(WND);
38public:
40 CHitTestAddinT(void) : _super()
41 {
42 }
43
45 virtual ~CHitTestAddinT(void)
46 {
48 }
49
57 bool AddArea(INDEX id, HRGN rgn)
58 {
59 HRGN h = ::CreateRectRgn(0, 0, 0, 0);
60 if ( ::CombineRgn(h, rgn, NULL, RGN_COPY) == ERROR )
61 {
62 return false;
63 }
64 TParam p = { id, h };
65 return m_areas.Add(p) != INVALID_INDEX;
66 }
67
75 bool AddArea(INDEX id, const RECT& rc)
76 {
77 HRGN h = ::CreateRectRgnIndirect(&rc);
78 if ( h == NULL )
79 {
80 return false;
81 }
82 TParam p = { id, h };
83 return m_areas.Add(p) != INVALID_INDEX;
84 }
85
89 void DeleteAllAreas(void)
90 {
91 loop ( i, m_areas.GetSize() )
92 {
93 _DeleteObject(m_areas[i].hRgn);
94 }
96 }
97
104 INDEX HitTest(const POINT& po) const
105 {
106 loop ( i, m_areas.GetSize() )
107 {
108 if ( ::PtInRegion(m_areas[i].hRgn, po.x, po.y) )
109 {
110 return m_areas[i].id;
111 }
112 }
113 return INVALID_INDEX;
114 }
115
116protected:
118 struct TParam
119 {
120 INDEX id;
121 HRGN hRgn;
122 };
133 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
134 {
135 switch ( message )
136 {
137 case WM_GETDLGCODE:
138 break;
139 default:
140 break;
141 }
142 return _super::WindowProc(message, wParam, lParam);
143 }
151 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const
152 {
153 INDEX idx = HitTest(point);
154 if ( idx != INVALID_INDEX )
155 {
156 return idx;
157 }
158 return -1;
159 }
160};
161
162
163
164}; //MFC
165}; //TNB
166
167
168
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
MFCコントロール共通のヘッダ
簡易配列型情報管理関係のヘッダ
void RemoveAll(void)
[削除] 空化
size_t GetSize(void) const
[取得] サイズ取得
INDEX Add(const TYP &t)
[追加] 要素一つ追加.
領域ヒットテストサポートクラス
Definition: TnbMfcHitTest.h:36
virtual ~CHitTestAddinT(void)
デストラクタ
Definition: TnbMfcHitTest.h:45
virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO *pTI) const
[確認] ヒットテスト.
INDEX HitTest(const POINT &po) const
[確認] ヒットテスト
CSimpleVectorT< TParam > m_areas
エリア管理
CHitTestAddinT(void)
コンストラクタ
Definition: TnbMfcHitTest.h:40
bool AddArea(INDEX id, const RECT &rc)
[追加] エリア設定.
Definition: TnbMfcHitTest.h:75
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
bool AddArea(INDEX id, HRGN rgn)
[追加] エリア設定.
Definition: TnbMfcHitTest.h:57
void DeleteAllAreas(void)
[削除] 全エリア情報破棄
Definition: TnbMfcHitTest.h:89
TNB Library
Definition: TnbDoxyTitle.txt:2