int CBlendSelectWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; m_dwTitleHeight = CalculateTitleHeight(); int nBtnLeft = (m_hIcon == NULL) ? m_dwMargin : (m_dwMargin * 2 + 32); int nBtnWidth = (m_hIcon == NULL) ? (m_dwWidth - 2 * m_dwMargin) : (m_dwWidth - 3 * m_dwMargin - 32); int nButTop = 2 * m_dwMargin + m_dwTitleHeight; m_wndListBox.SetTextColor(m_crText); m_wndListBox.SetBkColor(m_crBkgnd); m_wndListBox.SetRadioIcon(m_hIconCheck, m_hIconUnCheck); m_wndListBox.SetFont(&m_ftOption); CRect rcListBox(nBtnLeft, nButTop, nBtnLeft + nBtnWidth, nButTop); if (!m_wndListBox.Create(rcListBox, this, 0, WS_CHILD | WS_VISIBLE|WS_VSCROLL, RLS_HAS_RADIO)) return -1; m_dwHeight = m_dwMargin * 3 + m_dwTitleHeight + m_wndListBox.GetListHeight(); CRgn CaptionRegion; CaptionRegion.CreateRoundRectRgn(0, 0, m_dwWidth, m_dwHeight, 10, 10); SetWindowRgn((HRGN)CaptionRegion.m_hObject, TRUE); if (m_dwAnimateDelay > 0) { m_wAlpha = 0; DWORD dwInterval = m_dwAnimateDelay / 16; ::SetLayeredWindowAttributes(GetSafeHwnd(), 0, (BYTE)m_wAlpha, LWA_ALPHA); m_bAnimateInTimer = TRUE; SetTimer(TIMER_ID_ANIMATEIN, dwInterval, NULL); } else { m_wAlpha = 255; ::SetLayeredWindowAttributes(GetSafeHwnd(), 0, (BYTE)m_wAlpha, LWA_ALPHA); if (m_dwShowDelay > 0) { SetTimer(TIMER_ID_SHOW, m_dwShowDelay, NULL); m_bShowTimer = TRUE; } } return 0; }
void ESChildComboBox::ShowListBox(bool bHide /*= false*/){ if( bHide ){ if( m_pListBox ){ SendEvent(this, EventCode_ComboBoxCloseUp); _Rect rcListBox = m_pListBox->GetClientRect(); m_pListBox->SetVisible(false, false); m_pOwner->RemoveChildControl(m_pListBox); m_pListBox = NULL; RedrawRect (rcListBox, true); RedrawRect (m_rcBoxButton, true); } return; } if( m_pListBox == NULL ){ m_pListBox = new ESChildComboListBox(); int nItems = m_content.GetCount(); int nItemCY = m_pListBox->GetItemHeight(); int nListBoxHeight = m_nListBoxHeight; if( nListBoxHeight > nItems*nItemCY ){ nListBoxHeight = nItems*nItemCY; } _Rect rcListBox(m_rRect.left, m_rRect.bottom + 1, m_rRect.right, (m_rRect.bottom + 1) + nListBoxHeight); _Rect rcOwner; if( !m_pParent ) m_pOwner->GetClientRectMy(rcOwner); else rcOwner = m_pParent->GetClientRect(); if( rcOwner.bottom < rcListBox.bottom ){ rcListBox.bottom = m_rRect.top - 1; rcListBox.top = rcListBox.bottom - nListBoxHeight; } SendEvent(this, EventCode_ComboBoxDropDown); if( m_pOwner->AddChildControl(m_pListBox, MercuryBaseView::GetChildControlIdUnused(m_pOwner), rcListBox, m_pParent, 100) ){ for(int i=0; i<m_content.GetCount(); i++) m_pListBox->AddItem(m_content.GetKey(i), m_content.GetValueByIndex(i), false); m_pListBox->GetVScrollBar()->OwnerWindowSizeChanged(rcOwner.Width(), rcOwner.Height()); int nIndex = -1; if( m_content.KeyExists(GetText(), &nIndex) ) m_pListBox->SetSelectedItem(nIndex, false, true); m_pListBox->AddEventListener((ESFrameBase*)this, ChildControlEventCode::EventCode_ListBoxItemClick, (ControlEventListener)&ESChildComboBox::OnListBoxItemClick); m_pListBox->SetTextFont (&m_textFont, false); m_pOwner->RedrawRect (rcListBox, 1); RedrawRect (m_rcBoxButton, true); } else{ delete m_pListBox; m_pListBox = NULL; return; } } else{ for(int i=0; i<m_content.GetCount(); i++) m_pListBox->AddItem(m_content.GetKey(i), m_content.GetValueByIndex(i), false); int nIndex = -1; if( m_content.KeyExists(GetText(), &nIndex) ) m_pListBox->SetSelectedItem(nIndex, false, true); } }