ComboBox = NULL;
m_nMaxCount = 8;
m_aInfo.SetSize(0,8);
m_nMousePos = -1;
m_nBeginShow = 0;
}
CWndForACComboBox::~CWndForACComboBox()
{
}
BEGIN_MESSAGE_MAP(CWndForACComboBox, CWnd)
file://{{AFX_MSG_MAP(CWndForACComboBox)
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_KEYDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEWHEEL()
ON_WM_KILLFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_VSCROLL()
file://}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWndForACComboBox message handlers
BOOL CWndForACComboBox::Create(CComboBox * pWnd)
{
ASSERT(pWnd);
CRect rect;
CWnd * pParentWnd = pWnd->GetParent();
pWnd->GetWindowRect(&rect);
// pParentWnd->ScreenToClient(&rect);
BOOL bRet = CWnd::CreateEx( WS_EX_TOPMOST | WS_EX_TOOLWINDOW,\
lpWndCls, NULL, WS_POPUP | WS_VSCROLL, rect.left, rect.top, rect.Width(), rect.Height(),
pParentWnd->GetSafeHwnd(), NULL, NULL);
if(bRet)
SetOwner(pParentWnd);
m_pComboBox = pWnd;
return bRet;
}
void CWndForACComboBox::OnDestroy()
{
CWnd::OnDestroy();
m_aInfo.RemoveAll();
}
void CWndForACComboBox::OnPaint()
{
CRect rect;
CFont * pFont;
LOGFONT logFont;
if(m_pComboBox)
{
ASSERT(::IsWindow(m_pComboBox->GetSafeHwnd()));
CWnd * pParentWnd = m_pComboBox->GetParent();
m_pComboBox->GetWindowRect(&rect);
pFont = pParentWnd->GetFont();
ASSERT(pFont);
pFont->GetLogFont(&logFont);
if(logFont.lfHeight < 0) logFont.lfHeight = -logFont.lfHeight;
if(m_aInfo.GetSize() > m_nMaxCount)
{
logFont.lfWidth = m_nMaxCount * logFont.lfHeight;
}
else
{
logFont.lfWidth = m_aInfo.GetSize() * logFont.lfHeight;
}
if(logFont.lfWidth + rect.bottom > ::GetSystemMetrics(SM_CYSCREEN))
{
rect.bottom = rect.top;
rect.top = rect.bottom - logFont.lfWidth - 2;
if(rect.top < 0)
rect.top = 0;
}
else
{
rect.top = rect.bottom;
rect.bottom = rect.top + logFont.lfWidth + 2;
}
rect.right = rect.left + m_pComboBox->GetDroppedWidth();
// pParentWnd->ScreenToClient(&rect);
MoveWindow(&rect);
if(rect.Height() < m_aInfo.GetSize() * logFont.lfHeight)
{
TRACE("%d %d\r\n",rect.Height(),m_aInfo.GetSize() * logFont.lfHeight);
SCROLLINFO info;
info.cbSize = sizeof(info);
info.fMask = SIF_PAGE;
info.nPage = rect.Height() / logFont.lfHeight;
CWnd::SetScrollRange(SB_VERT,0,m_aInfo.GetSize() - 1,FALSE);
CWnd::ShowScrollBar(SB_VERT,TRUE);
CWnd::SetScrollInfo(SB_VER