本文整理汇总了C++中CGridListCtrlEx::GetFirstVisibleColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ CGridListCtrlEx::GetFirstVisibleColumn方法的具体用法?C++ CGridListCtrlEx::GetFirstVisibleColumn怎么用?C++ CGridListCtrlEx::GetFirstVisibleColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGridListCtrlEx
的用法示例。
在下文中一共展示了CGridListCtrlEx::GetFirstVisibleColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCellEditRect
//------------------------------------------------------------------------
//! Returns the proper rectangle, which a cell value editor should fit in
//!
//! @param owner The list control for the inplace cell value editor
//! @param nRow The index of the row
//! @param nCol The index of the column
//! @return Rectangle where the inplace cell value editor should be placed.
//------------------------------------------------------------------------
CRect CGridColumnTraitText::GetCellEditRect(CGridListCtrlEx& owner, int nRow, int nCol)
{
// Get position of the cell to edit
CRect rectCell;
VERIFY(owner.GetCellRect(nRow, nCol, LVIR_LABEL, rectCell));
// Adjust cell rectangle according to grid-lines
if (owner.GetExtendedStyle() & LVS_EX_GRIDLINES)
rectCell.bottom -= ::GetSystemMetrics(SM_CXBORDER);
if (nCol == 0 && owner.GetImageList(LVSIL_SMALL) != NULL)
{
// Add margin to cell image
rectCell.left += ::GetSystemMetrics(SM_CXBORDER);
}
else
{
if (nCol > 0 && (owner.GetExtendedStyle() & LVS_EX_SUBITEMIMAGES) && owner.GetImageList(LVSIL_SMALL) != NULL && owner.GetCellImage(nRow, nCol) != I_IMAGECALLBACK)
{
// Add margin to cell image
rectCell.left += ::GetSystemMetrics(SM_CXBORDER);
}
else
{
// Overlap the focus rectangle, unless we are first in column order
if (nCol != owner.GetFirstVisibleColumn())
rectCell.left -= ::GetSystemMetrics(SM_CXBORDER);
}
}
// Check if there is enough room for normal margin
int requiredHeight = GetCellFontHeight(owner);
requiredHeight += 2 * ::GetSystemMetrics(SM_CXEDGE);
if (requiredHeight > rectCell.Height())
rectCell.bottom = rectCell.top + requiredHeight;
return rectCell;
}
示例2: OnCustomDraw
//.........这里部分代码省略.........
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);
CRect rcIcon, rcCell;
VERIFY( owner.GetCellRect(nRow, nCol, LVIR_ICON, rcIcon) );
VERIFY( owner.GetCellRect(nRow, nCol, LVIR_BOUNDS, rcCell) );
// When the label column is placed first it has a left-margin
if (nCol==0 && nCol==owner.GetFirstVisibleColumn())
{
int cxborder = ::GetSystemMetrics(SM_CXBORDER);
rcCell.left += cxborder*2;
}
// Remove white margin between cell-image and cell-text
rcCell.right = rcIcon.right + 2;
CBrush brush(backColor);
pDC->FillRect(&rcCell, &brush);
// Draw icon
COLORREF oldBkColor = pImageList->SetBkColor(backColor);
pImageList->Draw ( pDC,
nImage,
rcIcon.TopLeft(),
ILD_NORMAL );
pImageList->SetBkColor(oldBkColor);
if (nCol==0 && owner.GetExtendedStyle() & LVS_EX_CHECKBOXES)
{
CImageList* pStateImageList = owner.GetImageList(LVSIL_STATE);
if (pImageList==NULL)
break;
int checkState = owner.GetCheck(nRow);
COLORREF oldStateBkColor = pStateImageList->SetBkColor(backColor);
pStateImageList->Draw ( pDC,
checkState,
rcCell.TopLeft(),
ILD_NORMAL );
pStateImageList->SetBkColor(oldStateBkColor);
}
} break;
}
// Perform standard drawing
CGridRowTraitText::OnCustomDraw(owner, pLVCD, pResult);
}
示例3: OnCustomDraw
//.........这里部分代码省略.........
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;
*pResult |= CDRF_NOTIFYPOSTPAINT;
}
else if (owner.GetExtendedStyle() & LVS_EX_GRIDLINES)
{
// Avoid bug where bottom of focus rectangle is missing when using grid-lines
// - Draw the focus-rectangle for the entire row (explicit)
pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
*pResult |= CDRF_NOTIFYPOSTPAINT;
}
}
}
}
break;
// After painting a row
case CDDS_ITEMPOSTPAINT:
{
if (m_pOldFont!=NULL)
{
// Restore the original font
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
CFont* pNewFont = pDC->SelectObject(m_pOldFont);
if (m_FontAllocated)
{
m_FontAllocated = false;
delete pNewFont;
}
m_pOldFont = NULL;
}
if (CRect(pLVCD->nmcd.rc)==CRect(0,0,0,0))
break;
if (owner.GetFocusRow()!=nRow)
break;
if (owner.GetFocus() != &owner)
break;
// Perform the drawing of the focus rectangle
if (owner.GetFocusCell() >= 0)
{
// Draw the focus-rectangle for a single-cell
CRect rcHighlight;
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
VERIFY( owner.GetCellRect(nRow, owner.GetFocusCell(), LVIR_BOUNDS, rcHighlight) );
int cxborder = ::GetSystemMetrics(SM_CXBORDER);
// When the label column is placed first it has a left-margin
if (owner.GetFocusCell()==0 && owner.GetFocusCell()==owner.GetFirstVisibleColumn())
{
rcHighlight.left += cxborder*2;
}
else
// Prevent focus rectangle to overlap with cell-image (Only room for this when not first column)
if (owner.GetFirstVisibleColumn()!=owner.GetFocusCell())
{
rcHighlight.left -= cxborder;
}
// Adjust rectangle according to grid-lines
if (owner.GetExtendedStyle() & LVS_EX_GRIDLINES)
{
rcHighlight.bottom -= cxborder;
}
pDC->DrawFocusRect(rcHighlight);
}
else if (owner.GetExtendedStyle() & LVS_EX_GRIDLINES)
{
// Avoid bug where bottom of focus rectangle is missing when using grid-lines
// - Draw the focus-rectangle for the entire row (explicit)
CRect rcHighlight;
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
// Using LVIR_BOUNDS to get the entire row-rectangle
VERIFY( owner.GetItemRect(nRow, rcHighlight, LVIR_BOUNDS) );
// Adjust rectangle according to grid-lines
int cxborder = ::GetSystemMetrics(SM_CXBORDER);
rcHighlight.bottom -= cxborder;
pDC->DrawFocusRect(rcHighlight);
}
}
break;
}
}