📄 idedit.cpp
字号:
// IDEdit.cpp : implementation file
//
#include "stdafx.h"
#include "FileMaSys.h"
#include "IDEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIDEdit
CIDEdit::CIDEdit()
{
m_bMaskKeyInProgress=FALSE;
}
CIDEdit::~CIDEdit()
{
}
BEGIN_MESSAGE_MAP(CIDEdit, CEdit)
//{{AFX_MSG_MAP(CIDEdit)
ON_WM_KEYDOWN()
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIDEdit message handlers
void CIDEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch (nChar)
{
case VK_DELETE:
case VK_INSERT: return;
}
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CIDEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if (!m_bMaskKeyInProgress)
{
if (!CheckChar(nChar)) return;
}
if (isprint(nChar))
{
// si un masque existe, on est en insert mode
int startPos, endPos;
GetSel(startPos, endPos);
SetSel(startPos, endPos+1);
Clear();
m_str.SetAt(endPos, nChar); // added this
}
else if (nChar == VK_BACK)
{
int startPos, endPos;
GetSel(startPos, endPos);
// sanity range check
if ((startPos == endPos) && (startPos >= 1) && (startPos <= m_str.GetLength()))
{
char c;
// get the masked literal representation
c=m_strLiteral[startPos-1];
if (c=='.')
{
SendMessage(WM_KEYDOWN,VK_LEFT,0);
SendMessage(WM_KEYDOWN,VK_LEFT,0);
}
else
{
SendMessage(WM_KEYDOWN,VK_LEFT,0);
SendMessage(WM_KEYDOWN,VK_SPACE,0);
// SendMessage(WM_KEYDOWN,VK_LEFT,0);
}
}
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
BOOL CIDEdit::CheckChar(UINT nChar)
{
UINT c;
// unselect all selections, if any
int startPos, endPos;
GetSel(startPos, endPos);
SetSel(-1, 0);
SetSel(startPos, startPos);
// check the key against the mask
GetSel(startPos, endPos);
// make sure the string is not longer than the mask
if (endPos >= m_strLiteral.GetLength())
{
if ((endPos==m_strLiteral.GetLength())&& (nChar==VK_BACK))
{
return TRUE;
}
MessageBeep((UINT)-1);
return FALSE;
}
// check to see if a literal is in this position
c = '_';
if (!m_strLiteral.IsEmpty())
c = m_strLiteral.GetAt(endPos);
if (c != '_')
{
SendChar(c);
GetSel(startPos, endPos);
}
return TRUE;
}
void CIDEdit::SendChar(UINT nChar)
{
m_bMaskKeyInProgress = TRUE;
#ifdef WIN32
AfxCallWndProc(this, m_hWnd, WM_CHAR, nChar, 1);
#else
SendMessage(WM_CHAR, nChar, 1);
#endif
m_bMaskKeyInProgress = FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -