-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveEdit.cpp
87 lines (80 loc) · 1.84 KB
/
MoveEdit.cpp
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
// MoveEdit.cpp : 實作檔
//
#include "stdafx.h"
#include "HM_Machine.h"
#include "MoveEdit.h"
// CMoveEdit
IMPLEMENT_DYNAMIC(CMoveEdit, CEdit)
CMoveEdit::CMoveEdit()
{
}
CMoveEdit::~CMoveEdit()
{
}
BEGIN_MESSAGE_MAP(CMoveEdit, CEdit)
ON_WM_RBUTTONDOWN()
ON_WM_CONTEXTMENU()
ON_WM_CHAR()
END_MESSAGE_MAP()
// CMoveEdit 訊息處理常式
void CMoveEdit::OnRButtonDown(UINT nFlags, CPoint point)
{
#ifdef MOVE
CString StrBuff;
switch (GetDlgCtrlID())
{
case IDC_EDITCOMABSVX:
StrBuff.Format(_T("%d"), MO_ReadLogicPosition(0));
SetWindowText(StrBuff);
break;
case IDC_EDITCOMABSVY:
StrBuff.Format(_T("%d"), MO_ReadLogicPosition(1));
SetWindowText(StrBuff);
break;
case IDC_EDITCOMABSVZ:
StrBuff.Format(_T("%d"), MO_ReadLogicPosition(2));
SetWindowText(StrBuff);
break;
default:
break;
}
#endif // MOVE
CEdit::OnRButtonDown(nFlags, point);
}
/*用來取消菜單*/
void CMoveEdit::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
}
void CMoveEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == '-')
{
CString StrBuff;
GetWindowText(StrBuff);
if (StrBuff.IsEmpty())
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
{
int nSource, nDestination;
GetSel(nSource, nDestination);
//此時選擇全部內容
if (nSource == 0 && nDestination == StrBuff.GetLength())
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
{
}
}
}
else if ((nChar >= '0' && nChar <= '9') || (nChar == 0x08) || (nChar == 0x10))
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
// 其它的键,都不響應
else
{
}
}