2026-10-04 00:04:20 +08:00
|
|
|
#include "stdafx.h"
|
2026-09-28 15:28:50 +08:00
|
|
|
#include "UIIInplaceComboBox.h"
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
|
#undef THIS_FILE
|
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
CUIIInplaceComboBox::CUIIInplaceComboBox()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CUIIInplaceComboBox::CUIIInplaceComboBox( int nItem, int nSubItem, CStringList *psList)
|
|
|
|
|
{
|
|
|
|
|
m_nItem = nItem;
|
|
|
|
|
m_nSubItem = nSubItem;
|
|
|
|
|
|
|
|
|
|
if ( psList != NULL)
|
|
|
|
|
{
|
|
|
|
|
m_sList.AddTail( psList );
|
|
|
|
|
}
|
|
|
|
|
m_bVK_ESCAPE = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CUIIInplaceComboBox::~CUIIInplaceComboBox()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CUIIInplaceComboBox, CComboBox)
|
|
|
|
|
//{{AFX_MSG_MAP(CUIIInplaceComboBox)
|
|
|
|
|
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 CUIIInplaceComboBox::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 CUIIInplaceComboBox::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 CUIIInplaceComboBox::OnNcDestroy()
|
|
|
|
|
{
|
|
|
|
|
CComboBox::OnNcDestroy();
|
|
|
|
|
delete this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUIIInplaceComboBox::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 CUIIInplaceComboBox::OnSize(UINT nType, int cx, int cy)
|
|
|
|
|
{
|
|
|
|
|
CComboBox::OnSize(nType, cx, cy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUIIInplaceComboBox::OnCloseup()
|
|
|
|
|
{
|
|
|
|
|
GetParent()->SetFocus();
|
|
|
|
|
GetParent()->Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUIIInplaceComboBox::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);
|
|
|
|
|
}
|
|
|
|
|
|