Files
envi-code/SourceCode/Code2026/PipelineCmd/AECInplaceComboBox.cpp
T
2026-09-28 15:28:50 +08:00

131 lines
2.6 KiB
C++

#include "stdafx.h"
#include "AECInplaceComboBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
AECInplaceComboBox::AECInplaceComboBox()
{
}
AECInplaceComboBox::AECInplaceComboBox( int nItem, int nSubItem, CStringList *psList)
{
m_nItem = nItem;
m_nSubItem = nSubItem;
if ( psList != NULL)
{
m_sList.AddTail( psList );
}
m_bVK_ESCAPE = FALSE;
}
AECInplaceComboBox::~AECInplaceComboBox()
{
}
BEGIN_MESSAGE_MAP(AECInplaceComboBox, CComboBox)
//{{AFX_MSG_MAP(AECInplaceComboBox)
ON_WM_CREATE()
ON_WM_NCDESTROY()
ON_WM_KILLFOCUS()
ON_WM_SIZE()
ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL AECInplaceComboBox::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return 1;
}
}
return CComboBox::PreTranslateMessage(pMsg);
}
int AECInplaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CComboBox::OnCreate(lpCreateStruct) == -1)
return -1;
CFont* font = GetParent()->GetFont();
SetFont(font);
POSITION pos = m_sList.GetHeadPosition();
while(pos != NULL)
{
AddString((LPCTSTR)(m_sList.GetNext(pos)));
}
SetFocus();
return 0;
}
void AECInplaceComboBox::OnNcDestroy()
{
CComboBox::OnNcDestroy();
delete this;
}
void AECInplaceComboBox::OnKillFocus(CWnd* pNewWnd)
{
int nIndex = GetCurSel();
CComboBox::OnKillFocus(pNewWnd);
CString str;
GetWindowText(str);
LV_DISPINFO lvDispinfo;
lvDispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
lvDispinfo.hdr.idFrom = GetDlgCtrlID();
lvDispinfo.hdr.code = LVN_ENDLABELEDIT;
lvDispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
lvDispinfo.item.iItem = m_nItem;
lvDispinfo.item.iSubItem = m_nSubItem;
lvDispinfo.item.pszText = m_bVK_ESCAPE ? NULL : LPTSTR((LPCTSTR)str);
lvDispinfo.item.cchTextMax = str.GetLength();
lvDispinfo.item.lParam = GetItemData(GetCurSel());
CWnd * pPParent = GetParent()->GetParent();
int nCtrlID = GetParent()->GetDlgCtrlID();
if(nIndex != CB_ERR && pPParent != NULL)
{
pPParent->SendMessage(WM_NOTIFY,nCtrlID,(LPARAM)&lvDispinfo);
}
PostMessage(WM_CLOSE);
}
void AECInplaceComboBox::OnSize(UINT nType, int cx, int cy)
{
CComboBox::OnSize(nType, cx, cy);
}
void AECInplaceComboBox::OnCloseup()
{
GetParent()->SetFocus();
}
void AECInplaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(nChar == VK_ESCAPE || nChar == VK_RETURN)
{
if( nChar == VK_ESCAPE)
m_bVK_ESCAPE = 1;
GetParent()->SetFocus();
return;
}
CComboBox::OnChar(nChar, nRepCnt, nFlags);
}