当前位置: 首页>>代码示例>>C++>>正文


C++ CGridListCtrlEx::GetFocusRow方法代码示例

本文整理汇总了C++中CGridListCtrlEx::GetFocusRow方法的典型用法代码示例。如果您正苦于以下问题:C++ CGridListCtrlEx::GetFocusRow方法的具体用法?C++ CGridListCtrlEx::GetFocusRow怎么用?C++ CGridListCtrlEx::GetFocusRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGridListCtrlEx的用法示例。


在下文中一共展示了CGridListCtrlEx::GetFocusRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnClickEditStart

//------------------------------------------------------------------------
//! Check if the cell is editable when clicked
//!
//! @param owner The list control being clicked
//! @param nRow The index of the row
//! @param nCol The index of the column
//! @param pt The position clicked, in client coordinates.
//! @param bDblClick Whether the position was double clicked
//! @return How should the cell editor be started (0 = No editor, 1 = Start Editor, 2 = Start Editor and block click-event)
//------------------------------------------------------------------------
int CGridColumnTraitImage::OnClickEditStart(CGridListCtrlEx& owner, int nRow, int nCol, CPoint pt, bool bDblClick)
{
	// Begin edit if the cell has focus already
	bool startEdit = nRow!=-1 && nCol!=-1 && owner.GetFocusRow()==nRow && owner.GetFocusCell()==nCol && !bDblClick;

	// Check if the cell can be edited without having focus first
	if (m_ToggleSelection)
	{
		if (nCol==0 && owner.GetExtendedStyle() & LVS_EX_CHECKBOXES)
		{
			CRect iconRect;
			if (!owner.GetCellRect(nRow, nCol, LVIR_ICON, iconRect) || !iconRect.PtInRect(pt))
			{
				CRect labelRect;
				if (owner.GetCellRect(nRow, nCol, LVIR_LABEL, labelRect) && !labelRect.PtInRect(pt))
					return 1;	// Clicked the checkbox for the label-column
			}
		}

		if (m_ImageIndexes.GetSize()<=1)
			return startEdit ? 1 : 0;	// No images to flip between

		CRect iconRect;
		if (!owner.GetCellRect(nRow, nCol, LVIR_ICON, iconRect) || !iconRect.PtInRect(pt))
			return startEdit ? 1 : 0;	// Didn't click the image icon

		return 2;	// Don't change focus or change selection
	}

	return startEdit ? 1 : 0;
}
开发者ID:noindom99,项目名称:repositorium,代码行数:41,代码来源:CGridColumnTraitImage.cpp

示例2: OnCustomDraw

void CGridColumnTraitText::OnCustomDraw(CGridListCtrlEx& owner, NMLVCUSTOMDRAW* pLVCD, LRESULT* pResult)
{
	int nRow = (int)pLVCD->nmcd.dwItemSpec;

	switch (pLVCD->nmcd.dwDrawStage)
	{
		// Before painting a cell
		case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
		{
			// Remove the selection color for the focus cell, to make it easier to see focus
			int nCol = pLVCD->iSubItem;
			if (pLVCD->nmcd.uItemState & CDIS_SELECTED && owner.GetFocusCell()==nCol && owner.GetFocusRow()==nRow)
			{
				pLVCD->nmcd.uItemState &= ~CDIS_SELECTED;
			}

			if (!owner.IsRowSelected(nRow) && owner.GetHotItem()!=nRow)
			{
				if (UpdateTextColor(pLVCD->clrText))
					*pResult |= CDRF_NEWFONT;

				if (UpdateBackColor(pLVCD->clrTextBk))
					*pResult |= CDRF_NEWFONT;

				// Only change cell colors when not selected / in focus
				if (owner.OnDisplayCellColor(nRow, nCol, pLVCD->clrText, pLVCD->clrTextBk))
					*pResult |= CDRF_NEWFONT;
			}

			LOGFONT newFont = {0};
			if (owner.OnDisplayCellFont(nRow, nCol, newFont))
			{
				CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
				CFont* pNewFont = new CFont;
				VERIFY( pNewFont->CreateFontIndirect(&newFont) );
				m_pOldFont = pDC->SelectObject(pNewFont);
				*pResult |= CDRF_NOTIFYPOSTPAINT;	// We need to restore the original font
				*pResult |= CDRF_NEWFONT;
			}
		} break;

		// After painting a cell
		case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
		{
			if (m_pOldFont!=NULL)
			{
				// Restore the original font
				CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
				CFont* pNewFont = pDC->SelectObject(m_pOldFont);
				delete pNewFont;
			}
		} break;
	}
}
开发者ID:lubing521,项目名称:important-files,代码行数:54,代码来源:CGridColumnTraitText.cpp

示例3: OnClickEditStart

//------------------------------------------------------------------------
//! Checks if the mouse click should start the cell editor (OnEditBegin)
//! Normally the cell needs to have focus first before cell editor can be started
//! - Except when using ToggleSelection, and have clicked a checkbox (image)
//! - Except when using SingleClickEdit, which makes it impossible to do double click
//!
//! @param owner The list control being clicked
//! @param nRow The index of the row
//! @param nCol The index of the column
//! @param pt The position clicked, in client coordinates.
//! @param bDblClick Whether the position was double clicked
//! @return How should the cell editor be started (0 = No editor, 1 = Start Editor, 2 = Start Editor and block click-event)
//------------------------------------------------------------------------
int CGridColumnTraitImage::OnClickEditStart(CGridListCtrlEx& owner, int nRow, int nCol, CPoint pt, bool bDblClick)
{
	// Begin edit if the cell has focus already
	bool startEdit = false;
	if (nRow != -1 && nCol != -1 && !bDblClick)
	{
		if (m_SingleClickEdit)
			startEdit = true;
		else
			if (owner.GetFocusRow() == nRow && owner.GetFocusCell() == nCol)
				startEdit = true;
	}

	// Check if the cell-image / cell-checkbox can be edited without having focus first
	if (m_ToggleSelection)
	{
		if (nCol == 0 && owner.GetExtendedStyle() & LVS_EX_CHECKBOXES)
		{
			CRect iconRect;
			if (!owner.GetCellRect(nRow, nCol, LVIR_ICON, iconRect) || !iconRect.PtInRect(pt))
			{
				CRect labelRect;
				if (owner.GetCellRect(nRow, nCol, LVIR_LABEL, labelRect) && !labelRect.PtInRect(pt))
					return 1;	// Clicked the checkbox for the label-column
			}
		}

		if (m_ImageCellEdit.GetSize()>1)
		{
			CRect iconRect;
			if (owner.GetCellRect(nRow, nCol, LVIR_ICON, iconRect) && iconRect.PtInRect(pt))
				return 2;	// Clicked the image-icon (Don't change focus or change selection)
		}
	}

	return startEdit ? 1 : 0;
}
开发者ID:cosim,项目名称:cgridlistctrlex,代码行数:50,代码来源:CGridColumnTraitImage.cpp

示例4: OnCustomDraw

//------------------------------------------------------------------------
//! Overrides the custom draw handler, to allow custom coloring of rows.
//!		- Fix white background for icon images
//!		- Fix white background between icon and cell text
//!
//! @param owner The list control drawing
//! @param pLVCD Pointer to NMLVCUSTOMDRAW structure
//! @param pResult Modification to the drawing stage (CDRF_NEWFONT, etc.)
//------------------------------------------------------------------------
void CGridRowTraitXP::OnCustomDraw(CGridListCtrlEx& owner, NMLVCUSTOMDRAW* pLVCD, LRESULT* pResult)
{
	if (owner.UsingVisualStyle())
	{
		// Perform standard drawing
		CGridRowTraitText::OnCustomDraw(owner, pLVCD, pResult);
		return;
	}
	
	// We are using classic- or XP-style
	int nRow = (int)pLVCD->nmcd.dwItemSpec;

	// Repair the standard drawing
	switch (pLVCD->nmcd.dwDrawStage)
	{
		case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
		{
			// We want to fix cell images
			*pResult |= CDRF_NOTIFYPOSTPAINT;
		} break;

		case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
		{
			// Fix CListCtrl selection drawing bug with white background for icon image
			// Fix CListCtrl selection drawing bug with white margin between icon and text
			int nCol = pLVCD->iSubItem;

			if (CRect(pLVCD->nmcd.rc)==CRect(0,0,0,0))
				break;

			int nImage = owner.GetCellImage(nRow, nCol);
			if (nImage == I_IMAGECALLBACK)
				break;
				
			CImageList* pImageList = owner.GetImageList(LVSIL_SMALL);
			if (pImageList==NULL)
				break;

			COLORREF backColor = COLORREF(-1);
			if (owner.GetExtendedStyle() & LVS_EX_TRACKSELECT && owner.GetHotItem()==nRow)
			{
#if(WINVER >= 0x0500)
				backColor = ::GetSysColor(COLOR_HOTLIGHT);
#else
				if (owner.IsRowSelected(nRow))
					backColor = ::GetSysColor(COLOR_HIGHLIGHT);
				else
					break;
#endif
			}
			else
			if (owner.IsRowSelected(nRow))
			{
				if (!(owner.GetExtendedStyle() & LVS_EX_FULLROWSELECT))
					break;	// No drawing of selection color without full-row-select

				if (m_InvertCellSelection && owner.GetFocusRow()==nRow && owner.GetFocusCell()==nCol)
				{
					// No drawing of selection color for focus cell
					if (pLVCD->clrTextBk > RGB(255,255,255))
						break;

					backColor = pLVCD->clrTextBk;
				}
				else
				{
					if (owner.GetFocus()!=&owner && !owner.IsCellEditorOpen())
					{
						// Selection color is different when not having focus
						if (owner.GetStyle() & LVS_SHOWSELALWAYS)
							backColor = ::GetSysColor(COLOR_BTNFACE);
						else
							break;	// no drawing of selection color when not in focus
					}
					else
					{
						backColor = ::GetSysColor(COLOR_HIGHLIGHT);
					}
				}
			}
			else
			{
				// Redraw with the given background color
				if (pLVCD->clrTextBk > RGB(255,255,255))
					break;	// If a color is more than white, then it is invalid

				backColor = pLVCD->clrTextBk;
			}

			CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);

//.........这里部分代码省略.........
开发者ID:Binggoo,项目名称:Common,代码行数:101,代码来源:CGridRowTraitXP.cpp

示例5: OnCustomDraw

//------------------------------------------------------------------------
//! Overrides the custom draw handler, to allow custom coloring of rows.
//!		- Focus rectangle display
//!		- Use font size to increase row-height, but keep cell font-size
//!		- Alternate row coloring
//!
//! @param owner The list control drawing
//! @param pLVCD Pointer to NMLVCUSTOMDRAW structure
//! @param pResult Modification to the drawing stage (CDRF_NEWFONT, etc.)
//------------------------------------------------------------------------
void CGridRowTraitText::OnCustomDraw(CGridListCtrlEx& owner, NMLVCUSTOMDRAW* pLVCD, LRESULT* pResult)
{
    int nRow = (int)pLVCD->nmcd.dwItemSpec;

    switch (pLVCD->nmcd.dwDrawStage)
    {
    case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
    {
        // Remove the selection color for the focus cell, to make it easier to see focus
        if (m_InvertCellSelection)
        {
            int nCol = pLVCD->iSubItem;
            if (pLVCD->nmcd.uItemState & CDIS_SELECTED)
            {
                if (owner.GetFocusCell()==nCol && owner.GetFocusRow()==nRow)
                {
                    pLVCD->nmcd.uItemState &= ~CDIS_SELECTED;
                }
            }
        }

        // Bug in Vista causes the cell color from previous cell to be used in the next
        // even if having reverted the cell coloring in subitem-post-paint
        if (pLVCD->clrText <= RGB(255,255,255) || pLVCD->clrTextBk <= RGB(255,255,255))
        {
            pLVCD->clrText = CLR_DEFAULT;
            pLVCD->clrTextBk = CLR_DEFAULT;

            if (UpdateTextColor(nRow, pLVCD->clrText))
                *pResult |= CDRF_NEWFONT;

            if (UpdateBackColor(nRow, pLVCD->clrTextBk))
                *pResult |= CDRF_NEWFONT;

            if (owner.OnDisplayRowColor(nRow, pLVCD->clrText, pLVCD->clrTextBk))
                *pResult |= CDRF_NEWFONT;
        }
    }
    break;

    // Before painting a row
    case CDDS_ITEMPREPAINT:
    {
        if (UpdateTextColor(nRow, pLVCD->clrText))
            *pResult |= CDRF_NEWFONT;

        if (UpdateBackColor(nRow, pLVCD->clrTextBk))
            *pResult |= CDRF_NEWFONT;

        if (owner.OnDisplayRowColor(nRow, pLVCD->clrText, pLVCD->clrTextBk))
            *pResult |= CDRF_NEWFONT;

        LOGFONT newFont = {0};
        if (owner.OnDisplayRowFont(nRow, newFont))
        {
            // New font provided
            CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
            CFont* pNewFont = new CFont;
            VERIFY( pNewFont->CreateFontIndirect(&newFont) );
            m_pOldFont = pDC->SelectObject(pNewFont);
            m_FontAllocated = true;
            *pResult |= CDRF_NOTIFYPOSTPAINT;	// We need to restore the original font
            *pResult |= CDRF_NEWFONT;
        }
        else
        {
            if (owner.GetFont()!=owner.GetCellFont())
            {
                // Using special cell font because of SetMargin()
                CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
                m_pOldFont = pDC->SelectObject(owner.GetCellFont());
                *pResult |= CDRF_NOTIFYPOSTPAINT;	// We need to restore the original font
                *pResult |= CDRF_NEWFONT;
            }
        }

        if (pLVCD->nmcd.uItemState & CDIS_FOCUS)
        {
            if (owner.GetFocus() != &owner)
                break;

            // If drawing focus row, then remove focus state and request to draw it later
            //	- Row paint request can come twice, with and without focus flag
            //	- Only respond to the one with focus flag, else DrawFocusRect XOR will cause solid or blank focus-rectangle
            if (owner.GetFocusRow() == nRow)
            {
                if (owner.GetFocusCell() >= 0)
                {
                    // We want to draw a cell-focus-rectangle instead of row-focus-rectangle
                    pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
//.........这里部分代码省略.........
开发者ID:strogo,项目名称:cgridlistctrlex,代码行数:101,代码来源:CGridRowTraitText.cpp


注:本文中的CGridListCtrlEx::GetFocusRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。