-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyEdit.cpp
159 lines (123 loc) · 4.04 KB
/
MyEdit.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
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
// MyEdit.cpp : implementation file
//
#include "stdafx.h"
#include "MyEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyEdit
CMyEdit::CMyEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_CONTEXTMENU()
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlers
void CMyEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
LPARAM lParam;
if (!GetParent()) return;
// Trasformo in coordinate relative alla finestra parent
ClientToScreen(&point);
GetParent()->ScreenToClient(&point);
lParam = MAKELONG(point.x, point.y);
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
::SendMessage(GetParent()->m_hWnd, WM_LBUTTONDBLCLK , (WPARAM) nFlags, lParam);
}
void CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
LPARAM lParam;
if (!GetParent()) return;
lParam = MAKELONG(point.x, point.y);
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
::SendMessage(GetParent()->m_hWnd, WM_CONTEXTMENU, (WPARAM) m_hWnd, lParam);
}
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
// se viene premuto il tasto Alt non deve scatenare alcuna azione
// (di default Alt viene passato alla finestra madre che lo passa ad autocad
// che lo interpreta come richiesta di menu)
if (pMsg->message == WM_SYSKEYDOWN)
if (pMsg->wParam == VK_MENU)
return TRUE;
if (GetParent() && (pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_DOWN || pMsg->wParam == VK_UP ||
pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ||
pMsg->wParam == VK_TAB))
{
::SendMessage(GetParent()->m_hWnd, WM_KEYDOWN, (WPARAM) pMsg->wParam, 0);
return 1;
}
else
return CEdit::PreTranslateMessage(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
// CMyMaskedEdit
CMyMaskedEdit::CMyMaskedEdit()
{
}
CMyMaskedEdit::~CMyMaskedEdit()
{
}
BEGIN_MESSAGE_MAP(CMyMaskedEdit, CMFCMaskedEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_CONTEXTMENU()
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlers
void CMyMaskedEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
if (!GetParent()) return;
LPARAM lParam;
lParam = MAKELONG(point.x, point.y);
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
::SendMessage(GetParent()->m_hWnd, WM_CONTEXTMENU, (WPARAM) m_hWnd, lParam);
}
void CMyMaskedEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
LPARAM lParam;
if (!GetParent()) return;
// Trasformo in coordinate relative alla finestra parent
ClientToScreen(&point);
GetParent()->ScreenToClient(&point);
lParam = MAKELONG(point.x, point.y);
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
::SendMessage(GetParent()->m_hWnd, WM_LBUTTONDBLCLK , (WPARAM) nFlags, lParam);
}
BOOL CMyMaskedEdit::PreTranslateMessage(MSG* pMsg)
{
// se viene premuto il tasto Alt non deve scatenare alcuna azione
// (di default Alt viene passato alla finestra madre che lo passa ad autocad
// che lo interpreta come richiesta di menu)
if (pMsg->message == WM_SYSKEYDOWN)
if (pMsg->wParam == VK_MENU)
return TRUE;
if (GetParent() && (pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_DOWN || pMsg->wParam == VK_UP ||
pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ||
pMsg->wParam == VK_TAB))
{
::SendMessage(GetParent()->m_hWnd, WM_KEYDOWN, (WPARAM) pMsg->wParam, 0);
return 1;
}
else
return CMFCMaskedEdit::PreTranslateMessage(pMsg);
}