DuiDesinger的属性窗口是一个CMFCPropertyGridCtrl,该控件部队del键做处理,最终del键会由CUIDesignerView处理,导致控件删除。
解决方法很简单,从CMFCPropertyGridCtrl继承一个类,该类处理del键,将del键转化成backspace键,完美!
#include "StdAfx.h"
#include "MyPropertyGridCtrl.h"
CMyPropertyGridCtrl::CMyPropertyGridCtrl(void)
{
}
CMyPropertyGridCtrl::~CMyPropertyGridCtrl(void)
{
}
BOOL CMyPropertyGridCtrl::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE)
{
pMsg->wParam = VK_BACK;
//if (m_pSel == NULL || !m_pSel->IsEnabled())
//{
//}
//else
//{
// ASSERT_VALID(m_pSel);
// if (!EditItem(m_pSel))
// {
// }
//}
//return TRUE;
}
/*else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_BACK)
{
if (m_pSel == NULL || !m_pSel->IsEnabled())
{
}
else
{
ASSERT_VALID(m_pSel);
if (!EditItem(m_pSel))
{
}
}
return TRUE;
}*/
return CMFCPropertyGridCtrl::PreTranslateMessage(pMsg);
}