Пример #1
0
void AutoSetColumnWidth( CListCtrl& list, int iColumn )
{
   int nAutoWidth;
   int nAutoHeaderWidth;

   list.SetColumnWidth( iColumn, LVSCW_AUTOSIZE );
   nAutoWidth = list.GetColumnWidth( iColumn );
   list.SetColumnWidth( iColumn, LVSCW_AUTOSIZE_USEHEADER );
   nAutoHeaderWidth = list.GetColumnWidth( iColumn );
   list.SetColumnWidth( iColumn, max( nAutoWidth, nAutoHeaderWidth ) );
}
Пример #2
0
// store the widths of the columns so we can restore them later
void CWList::retrieveHeaderParams(CListCtrl& clc)
{
	m_iColumnWidths.RemoveAll();

	for(int c=0; c< getColumnCount(); c++)
	{
		m_iColumnWidths.Add(clc.GetColumnWidth(c));
	}
}
Пример #3
0
// @pymethod int|PyCListCtrl|GetColumnWidth|Gets the width of the specified column in the list control.
PyObject *PyCListCtrl_GetColumnWidth( PyObject *self, PyObject *args )
{
	int col;
	if (!PyArg_ParseTuple( args, "i:GetColumnWidth", 
	                   &col)) // @pyparm int|first||Index of the column whose width is to be retrieved.
		return NULL;
	CListCtrl *pList = GetListCtrl(self);
	if (!pList) return NULL;
	GUI_BGN_SAVE;
	int width = pList->GetColumnWidth(col);
	GUI_END_SAVE;
	return Py_BuildValue("i", width);
}
Пример #4
0
BOOL CPrefsID3V2HidePage::OnInitDialog() 
{
	CSAPrefsSubDlg::OnInitDialog();

	int  nColumnCount;
	LPINT pColOrderArray;

	CListCtrl* pListCtrl = &(pMainDlg->m_lvtabPage1.m_ID3v2ListCtrl);
	CHeaderCtrl* pHeaderCtrl = pListCtrl->GetHeaderCtrl();
	
	if (pHeaderCtrl != NULL)
	{
		nColumnCount = pHeaderCtrl->GetItemCount();
		
		pColOrderArray = (LPINT) new int[nColumnCount];
		pListCtrl->GetColumnOrderArray(pColOrderArray, nColumnCount);

	}
	
	//Fill the Show columns listbox with nonzero width columns
	//Fill the Hide columns listbox with zero width columns
	int ncol;
	CString szValue;
	m_showcollistbox.ResetContent();
	for(int i=0; i<nColumnCount; i++)
		{
		ncol = pColOrderArray[i];
		szValue = pMainDlg->m_ID3v2colnamearray.GetAt(ncol);
		if(pListCtrl->GetColumnWidth(ncol))	m_showcollistbox.AddString(LPCTSTR(szValue));
		else m_hidecollistbox.AddString(LPCTSTR(szValue));
		}
	
	delete [] pColOrderArray;

	m_showcollistbox.SetSel(0,TRUE);
	m_hidecollistbox.SetSel(0,TRUE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #5
0
void CPrefsID3V2HidePage::ShowHideColumns()
{
	CListCtrl* pListCtrl = &(pMainDlg->m_lvtabPage1.m_ID3v2ListCtrl);

	int ncol;
	CString itemstr;
	//Set Hidecol list widths to zero
	int ncount = m_hidecollistbox.GetCount();
	if (ncount>0||ncount != LB_ERR)
	{
		ncol=-1;
		for(int i=0;i<ncount;i++)
		{
			m_hidecollistbox.GetText(i, itemstr);
			ncol = pMainDlg->FindID3v2ColNumFromName(itemstr);
			if(ncol!=-1)
			{
				pListCtrl->SetColumnWidth(ncol,0);
			}
		}
	}
	
	//Expand showcol list items if width is zero
	ncount = m_showcollistbox.GetCount();
	int nColWidth =0; 

	if (ncount>0||ncount != LB_ERR)
	{
		ncol=-1;
		for(int j=0;j<ncount;j++)
		{
			m_showcollistbox.GetText(j, itemstr);
			ncol = pMainDlg->FindID3v2ColNumFromName(itemstr);
			if(ncol!=-1)
			{
				if(pListCtrl->GetColumnWidth(ncol) == 0)
				{
				nColWidth = GetWidthForCol(ncol);
				pListCtrl->SetColumnWidth(ncol,nColWidth);
				}
			}
		}
	}
	//Set Column Order
	CHeaderCtrl* pHeaderCtrl = pListCtrl->GetHeaderCtrl();

	if (pHeaderCtrl != NULL)
	{
		int  nColumnCount = pHeaderCtrl->GetItemCount();
		
		LPINT pColOrderArray = (LPINT) new int[nColumnCount];

		int nshowcount = m_showcollistbox.GetCount();
		for(int k=0; k<nshowcount; k++)
		{
			m_showcollistbox.GetText(k, itemstr);
			ncol = pMainDlg->FindID3v2ColNumFromName(itemstr);
			pColOrderArray[k] = ncol;
		}

		int nhidecount = m_hidecollistbox.GetCount();
		for(int l=0; l<nhidecount; l++)
		{
			m_hidecollistbox.GetText(l, itemstr);
			ncol = pMainDlg->FindID3v2ColNumFromName(itemstr);
			pColOrderArray[nshowcount+l] = ncol;
		}

		pListCtrl->SetColumnOrderArray(nColumnCount, pColOrderArray);
		delete [] pColOrderArray;
	}

}
void CListCtrlComboBox::ShowEdit(int nItem,int nSubItem) {
    if (nItem < 0 || nSubItem < 0) return;
    if (m_pParentList == NULL) return ;
    CListCtrl *pCtrl = m_pParentList;
    CRect rect;
    m_pParentList = pCtrl;
//	m_pParentList->GetSubItemRect(nItem,nIndex,LVIR_LABEL,rcCtrl);

    // 列可见
    CHeaderCtrl* pHeader = (CHeaderCtrl*)pCtrl->GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount();
    if( nSubItem >= nColumnCount || pCtrl->GetColumnWidth(nSubItem) < 5 )
        return ;

    // 列偏移
    int offset = 0;
    for( int i = 0; i < nSubItem; i++ )
        offset += pCtrl->GetColumnWidth( i );

    pCtrl->GetItemRect( nItem, &rect, LVIR_BOUNDS );
    rect.top -= 2;
    if (rect.top < 0) rect.top = 0;
    // 滚动列,便于操作
    CRect rcClient;
    CSize size;
    pCtrl->GetClientRect( &rcClient );
//	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
    if( offset + rect.left < 0 ) {
        size.cx = offset + rect.left;
        size.cy = 0;
        pCtrl->Scroll( size );
        rect.left -= size.cx;
    } else if(offset + rect.left > rcClient.right ) {
        size.cx = offset + rect.left;
        size.cy = 0;
        pCtrl->Scroll( size );
        rect.left -= size.cx;
    }
    // 获取列的对齐方式
    LV_COLUMN lvcol;
    lvcol.mask = LVCF_FMT;
    pCtrl->GetColumn( nSubItem, &lvcol );
    DWORD dwStyle;
    if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
        dwStyle = ES_LEFT;
    else if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
        dwStyle = ES_RIGHT;
    else dwStyle = ES_CENTER;

    rect.left += offset + 1;
    if (nSubItem > 0)
        rect.right = rect.left + pCtrl->GetColumnWidth( nSubItem );
    else
        rect.right = rect.left + pCtrl->GetColumnWidth( nSubItem );

    if( rect.right > rcClient.right)
        rect.right = rcClient.right;

    rect.bottom = rect.top + 12 * rect.Height();

    CString strItem = pCtrl->GetItemText(nItem,nSubItem);
    pCtrl->ClientToScreen(rect);
    GetParent()->ScreenToClient(rect);
    MoveWindow(rect);
//	SetWindowPos(NULL, rect.left,rect.top,rect.Width(),rect.Height(), SWP_SHOWWINDOW);
//	pCtrl->ClientToScreen(rcClient);
//	GetParent()->ScreenToClient(rcClient);
//	pCtrl->SetWindowPos(this, rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height(), SWP_SHOWWINDOW);
    ShowWindow(SW_SHOW);
    SetWindowText(strItem);
    ::SetFocus(GetSafeHwnd());
    SetItemHeight(-1,13);
//设置对应选项
    int nIndex =  FindStringExact(0, strItem);
    if (nIndex < 0) nIndex = 0;
    SetCurSel(nIndex);
    m_nCurrentItem = nItem;
    m_nCurrentSubItem = nSubItem;
}
Пример #7
0
//
// ListControlHitTest()
//
// - helper function for using the custom tooltip control with a list control
//
int CMyToolTipWnd::ListControlHitTest(CPoint point, CListCtrl& listCtl, int nColumn)
{
	// get client position
	listCtl.ScreenToClient(&point);

	// get the index of the line under the cursor
	int nIndex = -1;
	int nFirstVisible = listCtl.GetTopIndex();
	int numVisible = listCtl.GetCountPerPage();
	CRect itemRect;
	for(int i=nFirstVisible;i<nFirstVisible+numVisible;i++)
	{
		if (listCtl.GetItemRect(i, &itemRect, LVIR_BOUNDS))
		{
			if (itemRect.PtInRect(point))
			{
				nIndex = i;
				break;
			}
		}
	}

	// bail out if not on a line
	if (nIndex < 0)
		return -1;

	// else the line was found, so return if the column doesn't matter
	if (nColumn < 0)
		return nIndex;

	// else need to check if the cursor is on the right column
	BOOL bShow = FALSE;
	BOOL bInPosition = FALSE;

	// check if the cursor is within the specified col
	CRect targetRect;
//	listCtl.ClientToScreen(&itemRect);
	targetRect.left = itemRect.left;
	// NCR-FFS Changed i to j
	for(int j=0;j<nColumn;j++)
		targetRect.left += listCtl.GetColumnWidth(j);
	targetRect.right = targetRect.left + listCtl.GetColumnWidth(nColumn);
	if ((point.x >= targetRect.left) && (point.x <= targetRect.right))
	{
		// point is in the proper column, so save the rect
		CRect rect;
		listCtl.GetItemRect(nIndex, &rect, LVIR_LABEL);
		m_location.x = rect.right;
		m_location.y = rect.top;
		// account for column padding
		m_location.x += 5;
		m_location.y -= 1;
		// return the line index
		listCtl.ClientToScreen(&m_location);
		return nIndex;
	}
	else
	{
		// not within the proper column
		return -1;
	}
}