SDC C-Project CF Review 프로그램
KYH
2021-06-07 fe67777d8335fb6adb3601e5ef1b31ff22ea6792
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
// PropertyGridInPlaceEdit.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
//
 
#include "stdafx.h"
#include "PropertyGridInPlaceEdit.h"
 
 
// CPropertyGridInPlaceEdit
 
IMPLEMENT_DYNAMIC(CPropertyGridInPlaceEdit, CEdit)
 
CPropertyGridInPlaceEdit::CPropertyGridInPlaceEdit(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID, CString sInitText)
{
  m_sInitText     = sInitText;
  m_bExitOnArrows = FALSE;
  m_Rect = rect;  // For bizarre CE bug.
 
  DWORD dwEditStyle = /*WS_BORDER|*/WS_CHILD|/*WS_VISIBLE|*/ES_AUTOHSCROLL|dwStyle;
  if (!Create(dwEditStyle, rect, pParent, nID))
    return;
 
  m_clrBack = GetSysColor(COLOR_WINDOW);
  m_clrText = GetSysColor(COLOR_WINDOWTEXT);
  m_Brush.CreateSolidBrush(m_clrBack);
 
  SetFont(pParent->GetFont());
 
  SetWindowText(m_sInitText);
  SetFocus();
 
  SetSel(0, -1);
  SetSel(-1, 0);
}
 
CPropertyGridInPlaceEdit::~CPropertyGridInPlaceEdit()
{
}
 
void CPropertyGridInPlaceEdit::SetColors(COLORREF clrBack, COLORREF clrText)
{
  m_clrBack = clrBack;
  m_clrText = clrText;
  m_Brush.DeleteObject();
  m_Brush.CreateSolidBrush(m_clrBack);
}
 
BEGIN_MESSAGE_MAP(CPropertyGridInPlaceEdit, CEdit)
    //{{AFX_MSG_MAP(CPropertyGridInPlaceEdit)
    ON_WM_KILLFOCUS()
    ON_WM_CHAR()
    ON_WM_KEYDOWN()
    ON_WM_GETDLGCODE()
    ON_WM_CREATE()
    ON_WM_CTLCOLOR_REFLECT( )
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
 
 
// CPropertyGridInPlaceEdit ¸Þ½ÃÁö Ã³¸®±âÀÔ´Ï´Ù.
 
 
void CPropertyGridInPlaceEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
  if ((nChar == VK_PRIOR || nChar == VK_NEXT ||
    nChar == VK_DOWN  || nChar == VK_UP   ||
    nChar == VK_RIGHT || nChar == VK_LEFT) &&
    (m_bExitOnArrows || GetKeyState(VK_CONTROL) < 0))
  {
    GetParent()->SetFocus();
    return;
  }
 
  CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
 
// As soon as this edit loses focus, kill it.
void CPropertyGridInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
  CEdit::OnKillFocus(pNewWnd);
  EndEdit();
}
 
void CPropertyGridInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
  if (nChar == VK_TAB || nChar == VK_RETURN)
  {
    GetParent()->SetFocus();    // This will destroy this window
    return;
  }
  if (nChar == VK_ESCAPE) 
  {
    CancelEdit();
    return;
  }
 
  CEdit::OnChar(nChar, nRepCnt, nFlags);
 
  //// Resize edit control if needed
  //
  //// Get text extent
  //CString str;
  //GetWindowText( str );
 
  //// add some extra buffer
  //str += _T("  ");
  //
  //CWindowDC dc(this);
  //CFont *pFontDC = dc.SelectObject(GetFont());
  //CSize size = dc.GetTextExtent( str );
  //dc.SelectObject( pFontDC );
  //   
  //// Get client rect
  //CRect ParentRect;
  //GetParent()->GetClientRect( &ParentRect );
  //
  //// Check whether control needs to be resized
  //// and whether there is space to grow
  //if (size.cx > m_Rect.Width())
  //{
  //    if( size.cx + m_Rect.left < ParentRect.right )
  //        m_Rect.right = m_Rect.left + size.cx;
  //    else
  //        m_Rect.right = ParentRect.right;
  //    MoveWindow( &m_Rect );
  //}
}
 
UINT CPropertyGridInPlaceEdit::OnGetDlgCode() 
{
  return DLGC_WANTALLKEYS;
}
 
////////////////////////////////////////////////////////////////////////////
// CPropertyGridInPlaceEdit overrides
 
// Stoopid win95 accelerator key problem workaround - Matt Weagle.
BOOL CPropertyGridInPlaceEdit::PreTranslateMessage(MSG* pMsg) 
{
  // Catch the Alt key so we don't choke if focus is going to an owner drawn button
  if (pMsg->message == WM_SYSCHAR)
    return TRUE;
  return CEdit::PreTranslateMessage(pMsg);
}
 
////////////////////////////////////////////////////////////////////////////
// CPropertyGridInPlaceEdit implementation
 
void CPropertyGridInPlaceEdit::CancelEdit()
{
  // restore previous text
  if (IsWindow(GetSafeHwnd()))
  {
    SetWindowText(m_sInitText);
    SendMessage(WM_CLOSE, 0, 0);
  }
}
 
void CPropertyGridInPlaceEdit::EndEdit()
{
  CString str;
 
  // EFW - BUG FIX - Clicking on a grid scroll bar in a derived class
  // that validates input can cause this to get called multiple times
  // causing assertions because the edit control goes away the first time.
  static BOOL bAlreadyEnding = FALSE;
 
  if(bAlreadyEnding)
    return;
 
  bAlreadyEnding = TRUE;
  GetWindowText(str);
 
  CWnd* pOwner = GetOwner();
  if (pOwner)
    pOwner->SendMessage(WM_PG_ENDLABELEDIT, (WPARAM) LPCTSTR(str), NULL );
 
  // Close this window (PostNcDestroy will delete this)
  if (IsWindow(GetSafeHwnd()))
    SendMessage(WM_CLOSE, 0, 0);
  bAlreadyEnding = FALSE;
}
 
HBRUSH CPropertyGridInPlaceEdit::CtlColor ( CDC* pDC, UINT nCtlColor )
{
  pDC->SetTextColor(m_clrText);
  pDC->SetBkColor(m_clrBack);
  return m_Brush;
}