-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseInterface.cpp
More file actions
66 lines (57 loc) · 1.7 KB
/
MouseInterface.cpp
File metadata and controls
66 lines (57 loc) · 1.7 KB
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
// MouseInterface.cpp: implementation of the CMouseInterface class.
//
//////////////////////////////////////////////////////////////////////
#include "MouseInterface.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMouseInterface::CMouseInterface()
{
m_cPrevPress = 0;
for (int i = 1; i < DEF_MAXRECTS; i++)
m_pRect[i] = NULL;
m_dwTime = timeGetTime();
}
CMouseInterface::~CMouseInterface()
{
for (int i = 1; i < DEF_MAXRECTS; i++)
if (m_pRect[i] != NULL) delete m_pRect[i];
}
void CMouseInterface::AddRect(long sx, long sy, long dx, long dy)
{
for (int i = 1; i < DEF_MAXRECTS; i++)
if (m_pRect[i] == NULL) {
m_pRect[i] = (RECT *) new RECT;
SetRect(m_pRect[i], sx, sy, dx, dy);
return ;
}
}
int CMouseInterface::iGetStatus(int msX, int msY, char cLB, char * pResult)
{
int i, iRet;
if (cLB != 0) {
// 아직 눌려진 버튼이 없다면
for (i = 1; i < DEF_MAXRECTS; i++)
if (m_pRect[i] != NULL) {
if ((m_pRect[i]->left < msX) && (m_pRect[i]->right > msX) &&
(m_pRect[i]->top < msY) && (m_pRect[i]->bottom > msY)) {
m_cPrevPress = i;
*pResult = DEF_MIRESULT_PRESS;
return i;
}
}
}
if ((m_cPrevPress != 0) && (cLB == 0)) {
//if (m_cPrevPress <= 0 ) return 0 ;
// 이전에 눌려진 버튼이 있고 버튼이 떼졌다. 클릭되었는지를 검사한다.
if ((m_pRect[m_cPrevPress]->left < msX) && (m_pRect[m_cPrevPress]->right > msX) &&
(m_pRect[m_cPrevPress]->top < msY) && (m_pRect[m_cPrevPress]->bottom > msY)) {
iRet = m_cPrevPress;
m_cPrevPress = 0;
*pResult = DEF_MIRESULT_CLICK;
return iRet;
}
}
*pResult = DEF_MIRESULT_NONE;
return 0;
}