Ejemplo n.º 1
0
LRESULT CStroeSet::PopulateComboList(WPARAM wParam, LPARAM lParam)
{
	// Get the Combobox window pointer
	CComboBox* pInPlaceCombo = static_cast<CComboBox*> (GetFocus());
	//去掉排序属性
	// 	DWORD nStyle   =   GetWindowLong(pInPlaceCombo->m_hWnd,GWL_STYLE);   
	// 	nStyle   =   nStyle &(~ LBS_SORT);   
	// 	SetWindowLong(pInPlaceCombo->m_hWnd,GWL_STYLE,nStyle);   

	CRect obWindowRect;
	pInPlaceCombo->GetWindowRect(&obWindowRect);
	//pInPlaceCombo->MoveWindow(obWindowRect.left,obWindowRect.top,obWindowRect.Width(),500);
	CPoint obInPlaceComboTopLeft(obWindowRect.TopLeft()); 
	// Get the active list
	// Get the control window rect
	// If the inplace combobox top left is in the rect then
	// The control is the active control
	m_List.GetWindowRect(&obWindowRect);

	int iColIndex = wParam;
	CStringList* pComboList = reinterpret_cast<CStringList*>(lParam);
	pComboList->RemoveAll();
	if (obWindowRect.PtInRect(obInPlaceComboTopLeft)) 
	{
		if (1 == iColIndex)
		{
			InitComString(pComboList);
		}		
	}
	return 0;
}
Ejemplo n.º 2
0
bool CPPageBase::FillComboToolTip(CComboBox& comboBox, TOOLTIPTEXT* pTTT)
{
    bool bNeedTooltip = false;

    CDC* pDC = comboBox.GetDC();
    CFont* pFont = comboBox.GetFont();
    CFont* pOldFont = pDC->SelectObject(pFont);

    TEXTMETRIC tm;
    pDC->GetTextMetrics(&tm);

    CRect comboBoxRect;
    comboBox.GetWindowRect(comboBoxRect);
    comboBoxRect.right -= GetSystemMetrics(SM_CXVSCROLL) + 2 * GetSystemMetrics(SM_CXEDGE);

    int i = comboBox.GetCurSel();
    CString str;
    comboBox.GetLBText(i, str);
    CSize textSize;
    textSize = pDC->GetTextExtent(str);
    pDC->SelectObject(pOldFont);
    comboBox.ReleaseDC(pDC);
    textSize.cx += tm.tmAveCharWidth;

    if (textSize.cx > comboBoxRect.Width()) {
        bNeedTooltip = true;
        if (str.GetLength() > _countof(pTTT->szText) - 1) {
            str.Truncate(_countof(pTTT->szText) - 1);
        }
        _tcscpy_s(pTTT->szText, str);
        pTTT->hinst = nullptr;
    }

    return bNeedTooltip;
}
Ejemplo n.º 3
0
void AutoSetComboBoxHeight(CComboBox& c)
{
	int itemCount = c.GetCount() + 1;
	int itemHeight = c.GetItemHeight(0);
	int editAreaHeight = c.GetItemHeight(0);
	int targetHeight = editAreaHeight + (itemHeight * itemCount);
	RECT rc;
	c.GetWindowRect(&rc);
	c.GetParent().ScreenToClient(&rc);
	rc.bottom = rc.top + targetHeight;
	c.MoveWindow(&rc, FALSE);
}
Ejemplo n.º 4
0
void CPlayerListCtrl::OnCbnDropdownCombo1()
{
    CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);

    CRect ir;
    GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);

    CRect r;
    pCombo->GetWindowRect(r);
    ScreenToClient(r);
    r.bottom = r.top + ir.Height() + pCombo->GetItemHeight(0) * 10;
    pCombo->MoveWindow(r);
}