Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

712 lines
18 KiB
C++

#include "stdafx.h"
#include <afxpriv.h> // WM_IDLEUPDATECMDUI definition
#include "InPlaceCtrls.h"
// Registered messages
static unsigned int const CT_IPCMsg = RegisterWindowMessage(IPCMSGSTRING);
#ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit class //
//////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP( CInPlaceEdit, CEdit )
//{{AFX_MSG_MAP(CInPlaceEdit)
ON_WM_CREATE()
ON_WM_KILLFOCUS()
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
IMPLEMENT_DYNCREATE( CInPlaceEdit, CEdit )
CInPlaceEdit::CInPlaceEdit()
{
m_hParent = NULL;
m_bIsNum = FALSE;
m_bReal = FALSE;
} // CInPlaceEdit::CInPlaceEdit
CInPlaceEdit::~CInPlaceEdit()
{
} // CInPlaceEdit::~CInPlaceEdit
void CInPlaceEdit::CreateCtrl(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent, CString sValue, BOOL bIsNum, BOOL bReal)
{
CInPlaceEdit* pEdit;
rect.bottom -= 1;
rect.left += 4;
if(pWndCtrl != NULL && pWndCtrl->IsKindOf(RUNTIME_CLASS(CInPlaceEdit)))
{
pEdit = (CInPlaceEdit*)pWndCtrl;
pEdit->SetReal(bReal);
if( bIsNum && pEdit->IsNum() || !bIsNum && !pEdit->IsNum() )
{
pWndCtrl->SetWindowText(sValue);
pWndCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
((CInPlaceEdit*)pWndCtrl)->SetSel(0, -1);
return;
}
}
if(pWndCtrl != NULL) delete pWndCtrl;
pEdit = new CInPlaceEdit();//| ES_MULTILINE
DWORD dStyle = WS_VISIBLE | WS_CHILD | ES_WANTRETURN | ES_NOHIDESEL | ES_AUTOHSCROLL ;//| WS_BORDER;
if( bIsNum )
dStyle |= ES_NUMBER;
pEdit->Create( dStyle, rect, pWndParent, 0);//| WS_CHILD | ES_AUTOHSCROLL |
pEdit->SetNum(bIsNum);
pEdit->SetReal(bReal);
pEdit->SetWindowText(sValue);
pEdit->SetSel(0, -1);
pWndCtrl = pEdit;
}
void CInPlaceEdit::CreateCtrl1(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent, CString sValue, BOOL bNum, BOOL bReal)
{
rect.DeflateRect(3, 2, 1, 0);
CInPlaceEdit* pEdit;
if(pWndCtrl != NULL && pWndCtrl->IsKindOf(RUNTIME_CLASS(CInPlaceEdit)))
{
pEdit = (CInPlaceEdit*)pWndCtrl;
pEdit->SetReal(bReal);
if( bNum && pEdit->IsNum() || !bNum && !pEdit->IsNum() )
{
pWndCtrl->SetWindowText(sValue);
pWndCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
pEdit->SetSel(0, -1);
return;
}
}
if(pWndCtrl != NULL) delete pWndCtrl;
pEdit = new CInPlaceEdit();
DWORD dStyle = WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL;
if( bNum ) dStyle |= ES_NUMBER;
pEdit->Create(dStyle, rect, pWndParent, 0);
pEdit->SetNum(bNum);
pEdit->SetReal(bReal);
pEdit->SetWindowText(sValue);
pEdit->SetSel(0, -1);
pWndCtrl = pEdit;
}
int CInPlaceEdit::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
if ( CEdit::OnCreate(lpCreateStruct) == -1 )
{
return -1;
}
SetFont(GetParent()->GetFont());
m_hParent = lpCreateStruct->hwndParent;
return 0;
} // CInPlaceEdit::OnCreate
void CInPlaceEdit::OnChange()
{
GetParent()->SendMessage(WM_USER_CHILDVALUECHANGED, 0, 0);
}
BOOL CInPlaceEdit::PreTranslateMessage( MSG *pMsg )
{
IPCENDINFO ipeEditInfo;
switch ( pMsg->message )
{
case WM_KEYDOWN:
if ( (int)pMsg->wParam == VK_ESCAPE ||
(int)pMsg->wParam == VK_RETURN ||
(int)pMsg->wParam == VK_TAB ||
(int)pMsg->wParam == VK_UP ||
(int)pMsg->wParam == VK_DOWN )
{
ZeroMemory( &ipeEditInfo, sizeof( ipeEditInfo ) );
ipeEditInfo.hwndSrc = m_hWnd;
ipeEditInfo.uKind = IPEK_KEY;
ipeEditInfo.nVirtKey = (int)pMsg->wParam;
ipeEditInfo.pt = pMsg->pt;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipeEditInfo );
return TRUE;
}
break;
}
return CEdit::PreTranslateMessage(pMsg);
} // CInPlaceEdit::PreTranslateMessage
void CInPlaceEdit::OnKillFocus( CWnd *pNewWnd )
{
// If the window is still visible, signal the parent
CEdit::OnKillFocus( pNewWnd );
GetParent()->SendMessage(WM_USER_CHILDVALUECHANGED, 0, 1);
if( pNewWnd && (pNewWnd->IsKindOf(RUNTIME_CLASS(CInPlaceButton))
|| pNewWnd->GetParent() == this->GetParent()
|| pNewWnd == this->GetParent()
|| (pNewWnd->IsKindOf(RUNTIME_CLASS(CSpinButtonCtrl))
&& ((CSpinButtonCtrl*)pNewWnd)->GetBuddy() == this))
)
return;
IPCENDINFO ipeEditInfo;
ZeroMemory( &ipeEditInfo, sizeof( ipeEditInfo ) );
if( pNewWnd )
{
ipeEditInfo.hNewWnd = pNewWnd->m_hWnd;
}
else
ipeEditInfo.hNewWnd = NULL;
ipeEditInfo.hwndSrc = m_hWnd;
ipeEditInfo.uKind = IPEK_KILLFOUCE;
ipeEditInfo.nVirtKey = 0;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipeEditInfo );
} // CInPlaceEdit::OnKillFocus
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(m_bReal)
{
int iSt, iEd;
CString sText;
GetWindowText(sText);
GetSel(iSt, iEd);
sText = sText.Left(iSt) + sText.Mid(iEd);
if(sText.IsEmpty()) sText = _T("A");
CPoint point = GetCaretPos();
if(!isprint(nChar)
|| isdigit(nChar) && (point.x < 1 && sText[0] != '+' && sText[0] != '-' || point.x > 1)
|| nChar == '.' && sText.Find('.') < 0 && (point.x < 1 && sText[0] != '+' && sText[0] != '-' || point.x > 1)
|| (nChar == '+' || nChar == '-') && point.x < 1 && sText[0] != '+' && sText[0] != '-')
CEdit ::OnChar(nChar, nRepCnt, nFlags);
}
else CEdit ::OnChar(nChar, nRepCnt, nFlags);
}
//////////////////////////////////////////////////////////////////////////////
// CInPlaceButton class //
//////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP( CInPlaceButton, CButton )
//{{AFX_MSG_MAP(CInPlaceButton)
ON_WM_CREATE()
ON_WM_KILLFOCUS()
ON_CONTROL_REFLECT(BN_CLICKED, OnClick)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
IMPLEMENT_DYNCREATE( CInPlaceButton, CButton )
CInPlaceButton::CInPlaceButton()
{
m_bMouseUp = TRUE;
m_hParent = NULL;
m_bInAction = FALSE;
} // CInPlaceButton::CInPlaceButton
CInPlaceButton::~CInPlaceButton()
{
} // CInPlaceButton::~CInPlaceButton
void CInPlaceButton::CreateCtrl(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent, CString sValue)
{
rect.left = rect.right - rect.Height();
if(pWndCtrl != NULL && pWndCtrl->IsKindOf(RUNTIME_CLASS(CInPlaceButton)))
{
pWndCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
return;
}
if(pWndCtrl != NULL) delete pWndCtrl;
CInPlaceButton* pButton = new CInPlaceButton();
pButton->Create(_T("..."), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW, rect, pWndParent, 0);//BS_OWNERDRAW
pWndCtrl = pButton;
}
void CInPlaceButton::CreateCtrl1(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent)
{
if (rect.Width() > rect.Height() + 4) rect.left = rect.right - rect.Height();
else
{
rect.left += 4;
rect.right = rect.left + rect.Height();
}
rect.InflateRect(2, 1, 0, 1);
if(pWndCtrl != NULL)
{
pWndCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
pWndCtrl->Invalidate();
return;
}
if(pWndCtrl != NULL) delete pWndCtrl;
CInPlaceButton* pButton = new CInPlaceButton();
pButton->Create(_T("..."), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW, rect, pWndParent, 0);
pWndCtrl = pButton;
}
int CInPlaceButton::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
if ( CButton::OnCreate(lpCreateStruct) == -1 )
{
return -1;
}
SetFont(GetParent()->GetFont());
m_hParent = lpCreateStruct->hwndParent;
return 0;
} // CInPlaceButton::OnCreate
void CInPlaceButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rect;
GetClientRect(rect);
CString sText;
GetWindowText(sText);
dc.DrawText(sText, rect, DT_SINGLELINE|DT_VCENTER);
dc.DrawEdge(rect, m_bMouseUp ? EDGE_RAISED : EDGE_SUNKEN, BF_RECT);
}
BOOL CInPlaceButton::PreTranslateMessage( MSG *pMsg )
{
IPCENDINFO ipcInfo;
switch ( pMsg->message )
{
case WM_KEYDOWN:
if ( (int)pMsg->wParam == VK_ESCAPE ||
(int)pMsg->wParam == VK_TAB )
{
ZeroMemory( &ipcInfo, sizeof( ipcInfo ) );
ipcInfo.hwndSrc = m_hWnd;
ipcInfo.uKind = IPEK_KEY;
ipcInfo.nVirtKey = (int)pMsg->wParam;
ipcInfo.pt = pMsg->pt;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipcInfo );
return TRUE;
}
break;
}
return CButton::PreTranslateMessage(pMsg);
} // CInPlaceButton::PreTranslateMessage
void CInPlaceButton::OnKillFocus( CWnd *pNewWnd )
{
// If the window is still visible, signal the parent
CButton::OnKillFocus( pNewWnd );
if(pNewWnd && (pNewWnd == this->GetParent() || pNewWnd->GetParent() == this->GetParent())) return;
IPCENDINFO ipeEditInfo;
ZeroMemory( &ipeEditInfo, sizeof( ipeEditInfo ) );
if( pNewWnd )
ipeEditInfo.hNewWnd = pNewWnd->m_hWnd;
else
ipeEditInfo.hNewWnd = NULL;
ipeEditInfo.hwndSrc = m_hWnd;
ipeEditInfo.uKind = IPEK_KILLFOUCE;
ipeEditInfo.nVirtKey = 0;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipeEditInfo );
} // CInPlaceButton::OnKillFocus
void CInPlaceButton::OnLButtonDown(UINT nFlags, CPoint point)
{
CButton::OnLButtonDown(nFlags, point);
m_bMouseUp = FALSE;
Invalidate();
}
void CInPlaceButton::OnLButtonUp(UINT nFlags, CPoint point)
{
CButton::OnLButtonUp(nFlags, point);
m_bMouseUp = TRUE;
Invalidate();
}
void CInPlaceButton::OnClick()
{
GetParent()->SendMessage(WM_USER_CHILDVALUECHANGED, 2, 0);
IPCENDINFO ipcEventInfo;
TRACE( "IPB: BN_CLICK\n" );
ZeroMemory( &ipcEventInfo, sizeof( ipcEventInfo ) );
ipcEventInfo.uKind = IPEK_ACTION;
ipcEventInfo.uID = GetWindowLong( m_hWnd, GWL_ID );
ipcEventInfo.pt.x = LOWORD( GetMessagePos() );
ipcEventInfo.pt.y = HIWORD( GetMessagePos() );
m_bInAction = TRUE;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipcEventInfo );
m_bInAction = FALSE;
} // CInPlaceButton::OnClick
//////////////////////////////////////////////////////////////////////////
// CInPlaceComboBox //
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE( CInPlaceComboBox, CComboBox )
CInPlaceComboBox::CInPlaceComboBox()
{
m_bDrop = FALSE;
m_bList = FALSE;
m_rect = CRect(0, 0, 0, 0);
}
CInPlaceComboBox::~CInPlaceComboBox()
{
}
BEGIN_MESSAGE_MAP(CInPlaceComboBox, CComboBox)
//{{AFX_MSG_MAP(CInPlaceComboBox)
ON_WM_CREATE()
ON_WM_KILLFOCUS()
ON_WM_PAINT()
ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropdown)
ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
ON_CONTROL_REFLECT(CBN_SELENDOK, OnSelendok)
ON_CONTROL_REFLECT(CBN_EDITCHANGE, OnEditchange)
ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillfocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInPlaceComboBox message handlers
BOOL CInPlaceComboBox::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
IPCENDINFO ipcInfo;
switch ( pMsg->message )
{
case WM_KEYDOWN:
if ( (int)pMsg->wParam == VK_ESCAPE ||
(int)pMsg->wParam == VK_RETURN ||
(int)pMsg->wParam == VK_TAB )
{
ZeroMemory( &ipcInfo, sizeof( ipcInfo ) );
ipcInfo.hwndSrc = m_hWnd;
ipcInfo.uKind = IPEK_KEY;
ipcInfo.nVirtKey = (int)pMsg->wParam;
ipcInfo.pt = pMsg->pt;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipcInfo );
return TRUE;
}
break;
}
return CComboBox::PreTranslateMessage(pMsg);
}
void CInPlaceComboBox::CreateCtrl(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent, CString sValue, CStringArray &strArr, UINT nHeight, BOOL bList)
{
int iIndex;
rect.InflateRect(0, 2, 0, 0);
CRect rcTemp = rect;
rcTemp.bottom += nHeight;
CInPlaceComboBox* pCombo;
rcTemp.top--;
if(pWndCtrl != NULL && pWndCtrl->IsKindOf(RUNTIME_CLASS(CInPlaceComboBox)))
{
pCombo = (CInPlaceComboBox*)pWndCtrl;
if(bList && pCombo->IsList() || !bList && !pCombo->IsList())
{
pCombo->ResetContent();
if( &strArr != NULL )
{
for(int i = 0; i < strArr.GetSize(); i++)
{
pCombo->AddString(strArr[i]);
}
}
//if( !sValue.IsEmpty() )
//{
if((iIndex = pCombo->FindStringExact( -1, sValue )) < 0 && !sValue.IsEmpty())
{
pCombo->InsertString( 0, sValue );
iIndex = 0;
}
//}
//else
// iIndex = 0;
pCombo->SetCurSel( iIndex );
if(!bList)
pCombo->SetEditSel(-1, 0);
pWndCtrl->SetWindowPos(NULL, rcTemp.left, rcTemp.top, rcTemp.Width(), rcTemp.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
pWndParent->ClientToScreen(rect);
pCombo->ScreenToClient(rect);
pCombo->SetFrameRect(rect, bList);
return;
}
}
if(pWndCtrl != NULL) delete pWndCtrl;
DWORD dwStyle = WS_VISIBLE | WS_CHILD | CBS_AUTOHSCROLL | WS_VSCROLL ;
if(bList) dwStyle |= CBS_DROPDOWNLIST;
else dwStyle |= CBS_DROPDOWN;
pCombo = new CInPlaceComboBox();
pCombo->Create(dwStyle, rcTemp, pWndParent, 0);
pCombo->ResetContent();
if( &strArr != NULL )
{
for(int i = 0; i < strArr.GetSize(); i++)
{
pCombo->AddString(strArr[i]);
}
}
//if( !sValue.IsEmpty() )
//{
if((iIndex = pCombo->FindStringExact( -1, sValue )) < 0 && !sValue.IsEmpty())
{
pCombo->InsertString( 0, sValue );
iIndex = 0;
}
//}
//else
// iIndex = 0;
pCombo->SetCurSel( iIndex );
if(!bList)
pCombo->SetEditSel(-1, 0);
pWndCtrl = pCombo;
pWndParent->ClientToScreen(rect);
pCombo->ScreenToClient(rect);
pCombo->SetFrameRect(rect, bList);
}
void CInPlaceComboBox::CreateCtrl1(CWnd *&pWndCtrl, CRect rect, CWnd *pWndParent, CString sValue, CStringList* pStrList, UINT nHeight, BOOL bList)
{
rect.InflateRect(1, 1, 0, 0);
CRect rcTemp = rect;
rcTemp.bottom += nHeight;
CInPlaceComboBox* pCombo;
rcTemp.top--;
if(pWndCtrl != NULL && pWndCtrl->IsKindOf(RUNTIME_CLASS(CInPlaceComboBox)))
{
pCombo = (CInPlaceComboBox*)pWndCtrl;
if(bList && pCombo->IsList() || !bList && !pCombo->IsList())
{
pCombo->ResetContent();
if(pStrList != NULL)
{
POSITION pos = pStrList->GetHeadPosition();
while(pos != NULL)
{
CString sText = pStrList->GetNext(pos);
pCombo->AddString(sText);
}
}
int iIndex = pCombo->FindStringExact(-1, sValue);
if(iIndex < 0 && !sValue.IsEmpty()) {iIndex = 0; pCombo->InsertString(0, sValue);}
pCombo->SetCurSel(iIndex);
pWndCtrl->SetWindowPos(NULL, rcTemp.left, rcTemp.top, rcTemp.Width(), rcTemp.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
pWndParent->ClientToScreen(rect);
pCombo->ScreenToClient(rect);
pCombo->SetFrameRect(rect, bList);
return;
}
}
if(pWndCtrl != NULL) delete pWndCtrl;
DWORD dwStyle = WS_VISIBLE|WS_CHILD|CBS_AUTOHSCROLL | WS_VSCROLL ;
if(bList) dwStyle |= CBS_DROPDOWNLIST;
else dwStyle |= CBS_DROPDOWN;
pCombo = new CInPlaceComboBox();
pCombo->Create(dwStyle, rcTemp, pWndParent, 0);
pWndCtrl = pCombo;
if(pStrList != NULL)
{
POSITION pos = pStrList->GetHeadPosition();
while(pos != NULL)
{
CString sText = pStrList->GetNext(pos);
pCombo->AddString(sText);
}
}
int iIndex = pCombo->FindStringExact(-1, sValue);
if(iIndex < 0 && !sValue.IsEmpty()) {iIndex = 0; pCombo->InsertString(0, sValue);}
pCombo->SetCurSel(iIndex);
pWndParent->ClientToScreen(rect);
pCombo->ScreenToClient(rect);
pCombo->SetFrameRect(rect, bList);
}
int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CComboBox::OnCreate(lpCreateStruct) == -1)
return -1;
SetFont(GetParent()->GetFont());
m_hParent = lpCreateStruct->hwndParent;
// TODO: Add your specialized creation code here
return 0;
}
void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
{
CComboBox::OnKillFocus(pNewWnd);
/*
IPCENDINFO ipeEditInfo;
ZeroMemory( &ipeEditInfo, sizeof( ipeEditInfo ) );
if( pNewWnd )
ipeEditInfo.hNewWnd = pNewWnd->m_hWnd;
else
ipeEditInfo.hNewWnd = NULL;
ipeEditInfo.hwndSrc = m_hWnd;
ipeEditInfo.uKind = IPEK_KILLFOUCE;
ipeEditInfo.nVirtKey = 0;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipeEditInfo );
Invalidate();*/
}
void CInPlaceComboBox::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect, rectText;
GetClientRect(rect);
int iHeight = rect.Height() - 2;
rectText = rect;
CString sText;
GetWindowText(sText);
rect.DeflateRect(2, 2, 2, 2);
//rectText.DeflateRect(4, 4, iHeight-2, 4);
rectText.DeflateRect(4, 4, 4, 4);
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
dc.SetBkColor(::GetSysColor(COLOR_WINDOW));
if(GetFocus() == this)
{
dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
dc.ExtTextOut(rect.left, rect.top, ETO_OPAQUE, rect, _T(""), 0, NULL);
}
CFont* pOldFont = dc.SelectObject(GetFont());
dc.DrawText(sText, rectText, DT_SINGLELINE|DT_VCENTER);
dc.SelectObject(pOldFont);
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
//rect = m_rect;
GetClientRect(rect);
rect.top += 1;
rect.bottom = rect.top + m_rect.Height();
//CPen pen(PS_SOLID, 1, RGB(198, 198, 198));
CPen pen(PS_SOLID, 1, ::GetSysColor(COLOR_BTNFACE));
CPen* pOldPen = dc.SelectObject(&pen);
dc.MoveTo(rect.right, rect.top);
dc.LineTo(rect.TopLeft());
dc.LineTo(rect.left, rect.bottom);
dc.LineTo(rect.BottomRight());
dc.SelectObject(pOldPen);
if (rect.Width() > iHeight + 4) rect.left = rect.right - iHeight;
else
{
rect.left += 4;
rect.right = rect.left + iHeight;
}
dc.DrawFrameControl(rect, DFC_SCROLL, m_bDrop ? DFCS_SCROLLDOWN|DFCS_PUSHED : DFCS_SCROLLDOWN);
}
void CInPlaceComboBox::OnDropdown()
{
// TODO: Add your control notification handler code here
m_bDrop = TRUE;
CRect rect;
GetClientRect(rect);
rect.left = rect.right - rect.Height();
InvalidateRect(rect, FALSE);
}
void CInPlaceComboBox::OnCloseup()
{
// TODO: Add your control notification handler code here
m_bDrop = FALSE;
CRect rect;
GetClientRect(rect);
rect.left = rect.right - rect.Height();
InvalidateRect(rect, FALSE);
}
void CInPlaceComboBox::SetFrameRect(CRect rect, BOOL bList)
{
m_rect = rect;
m_bList = bList;
}
void CInPlaceComboBox::OnEditchange()
{
GetParent()->SendMessage(WM_USER_CHILDVALUECHANGED, 1, 0);
}
void CInPlaceComboBox::OnSelendok()
{
SetCurSel(GetCurSel());
GetParent()->SendMessage(WM_USER_CHILDVALUECHANGED, 1, 1);
}
void CInPlaceComboBox::OnKillfocus()
{
IPCENDINFO ipeEditInfo;
ZeroMemory( &ipeEditInfo, sizeof( ipeEditInfo ) );
ipeEditInfo.hNewWnd = NULL;
ipeEditInfo.hwndSrc = m_hWnd;
ipeEditInfo.uKind = IPEK_KILLFOUCE;
ipeEditInfo.nVirtKey = 0;
::SendMessage( m_hParent, CT_IPCMsg, 0, (LPARAM)&ipeEditInfo );
Invalidate();
}