本文整理汇总了C++中CHeaderCtrl类的典型用法代码示例。如果您正苦于以下问题:C++ CHeaderCtrl类的具体用法?C++ CHeaderCtrl怎么用?C++ CHeaderCtrl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CHeaderCtrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHeaderCtrl
int CListCtrlEx::GetColumnCount()
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
if(pHeaderCtrl!=NULL)
return pHeaderCtrl->GetItemCount();
else
return 0;
}
示例2: add_col
int CKInputDlg::add_col(CString heading)
{
CHeaderCtrl* pHeaderCtrl = m_resList.GetHeaderCtrl();
if (pHeaderCtrl != NULL)
return m_resList.InsertColumn(pHeaderCtrl->GetItemCount(),heading
,LVCFMT_LEFT,KK_COL_WIDTH(heading.GetLength()));
return 0;
}
示例3: ShowInPlaceComboBox
CComboBox* CSHListCtrl::ShowInPlaceComboBox(int nItem, int nSubitem,DWORD dwStyle)
{
// The returned pointer should not be saved
// Make sure that the item is visible
// My code start here
if (!EnsureVisible(nItem, TRUE) )
return NULL;
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if( nSubitem >= nColumnCount || GetColumnWidth(nSubitem) < 10 )
return NULL;
// Get the column offset
int offset = 0;
for(int i = 0; i < nSubitem; i++)
offset += GetColumnWidth(i);
CRect rect;
GetItemRect(nItem, &rect, LVIR_BOUNDS);
// Now scroll if we need to expose the column
CRect rcClient;
GetClientRect(&rcClient);
if(offset + rect.left < 0 || offset + rect.left > rcClient.right)
{
CSize size;
size.cx = offset + rect.left;
size.cy = 0;
Scroll(size);
rect.left -= size.cx;
}
rect.left += offset;
rect.right = rect.left + GetColumnWidth( nSubitem ) ;
int height = rect.bottom - rect.top;
rect.bottom += 22 * height;
if (rect.right > rcClient.right)
rect.right = rcClient.right;
dwStyle |= WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DISABLENOSCROLL;
CComboBox* pList = new CSHInPlaceComboBox(nItem, nSubitem);
pList->Create(dwStyle, rect, this, IDC_INPLACE_COMBOBOX);
pList->SetItemHeight(-1, height);
pList->SetHorizontalExtent(GetColumnWidth(nSubitem));
CString strWindowText = GetItemText(nItem, nSubitem);
if(dwStyle & CBS_DROPDOWN && !(dwStyle & CBS_DROPDOWNLIST))
{
CEdit* m_pEdit = new CEdit();
m_pEdit->SubclassWindow(pList->GetDlgItem(1001)->GetSafeHwnd());
m_pEdit->SetWindowText(strWindowText);
m_pEdit->SetSel(0,-1);
}
return pList;
// My code end here
}
示例4: GetCurrentMessage
void CGridListCtrl::OnPaint()
{
// Make the gridlines easier to see than default light grey
// First let the control do its default drawing.
const MSG *pMsg = GetCurrentMessage();
DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam);
// Draw the lines only for LVS_REPORT mode
if ((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) {
CClientDC dc(this);
CPen NewPen(PS_SOLID, 0, m_RGBLineColour);
CPen *pOldPen = dc.SelectObject(&NewPen);
// Get the number of columns
CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(m_HeaderCtrlID);
int nColumnCount = pHeader->GetItemCount();
// The bottom of the header corresponds to the top of the line
RECT rect;
pHeader->GetClientRect(&rect);
int top = rect.bottom;
// Now get the client rect so we know the line length and when to stop
GetClientRect(&rect);
// The border of the column is offset by the horz scroll
int borderx = 0 - GetScrollPos(SB_HORZ);
for (int i = 0; i < nColumnCount; i++) {
// Get the next border
borderx += GetColumnWidth(pHeader->OrderToIndex(i));
// if next border is outside client area, break out
if (borderx >= rect.right) break;
// Draw the line.
dc.MoveTo(borderx - 1, top);
dc.LineTo(borderx - 1, rect.bottom);
}
// Draw the horizontal grid lines
// First get the height
if (!GetItemRect(0, &rect, LVIR_BOUNDS))
return;
int height = rect.bottom - rect.top;
GetClientRect(&rect);
int width = rect.right;
for (int i = 1; i <= GetCountPerPage(); i++) {
dc.MoveTo(0, top + height * i);
dc.LineTo(width, top + height * i);
}
dc.SelectObject(pOldPen);
}
}
示例5: EditSubLabel
// EditSubLabel - Start edit of a sub item label
// Returns - Temporary pointer to the new edit control
// nItem - The row index of the item to edit
// nCol - The column of the sub item.
CEdit* CVarListCtrl::EditSubLabel( int nItem, int nCol )
{
// The returned pointer should not be saved
// Make sure that the item is visible
//if( !EnsureVisible( nItem, TRUE ) ) return NULL;
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if( nCol >= nColumnCount || GetColumnWidth(nCol) < 5 )
return NULL;
// Get the column offset
int offset = 0;
for( int i = 0; i < nCol; i++ )
offset += GetColumnWidth( i );
CRect rect;
GetItemRect( nItem, &rect, LVIR_BOUNDS );
// Now scroll if we need to expose the column
CRect rcClient;
GetClientRect( &rcClient );
if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
{
CSize size;
size.cx = offset + rect.left;
size.cy = 0;
Scroll( size );
rect.left -= size.cx;
}
// Get Column alignment
LV_COLUMN lvcol;
lvcol.mask = LVCF_FMT;
GetColumn( nCol, &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+4;
rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
if( rect.right > rcClient.right) rect.right = rcClient.right;
dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
CEdit *pEdit = new CVarListEdit(nItem, nCol, GetItemText( nItem, nCol ));
pEdit->Create( dwStyle, rect, this, 2020 );
return pEdit;
}
示例6: GetListCtrl
void CSiriusView::OnDestroy()
{
HDITEM hdi;
// store columns width
CHeaderCtrl *pHdr = GetListCtrl().GetHeaderCtrl();
hdi.mask = HDI_WIDTH;
pHdr->GetItem(0, &hdi);
g_Settings.m_iListSrcAddr = hdi.cxy;
pHdr->GetItem(2, &hdi);
g_Settings.m_iListDestAddr = hdi.cxy;
pHdr->GetItem(1, &hdi);
g_Settings.m_iListSrcPort = hdi.cxy;
pHdr->GetItem(3, &hdi);
g_Settings.m_iListDestPort = hdi.cxy;
pHdr->GetItem(4, &hdi);
g_Settings.m_iListProto = hdi.cxy;
pHdr->GetItem(5, &hdi);
g_Settings.m_iListTraffic = hdi.cxy;
pHdr->GetItem(6, &hdi);
g_Settings.m_iListBS = hdi.cxy;
pHdr->GetItem(7, &hdi);
g_Settings.m_iListABS = hdi.cxy;
if (g_bStarted) {
OnCommandStop();
g_bStarted = FALSE;
}
CListView::OnDestroy();
}
示例7: GetHeaderCtrl
void CListCtrlEx::ReadState(LPCSTR pszName)
{
CHeaderCtrl* pHdr = GetHeaderCtrl ();
int *piWidthes;
Initialize ();
LPBYTE pbW, pbI;
UINT uSizeI, uSizeW;
CString strIndexes = pszName, strWidthes = pszName;
strIndexes += 'I';
strWidthes += 'W';
if (_App.GetProfileBinary (_T ("Settings\\View\\ListViews"), strIndexes, &pbI, &uSizeI) &&
_App.GetProfileBinary (_T ("Settings\\View\\ListViews"), strWidthes, &pbW, &uSizeW) &&
uSizeI == m_cTotalCols * sizeof (int) && uSizeW == m_cTotalCols * sizeof (int))
{
CopyMemory (m_aIndex, pbI, m_cTotalCols * sizeof (int));
piWidthes = (int*) pbW;
int i = m_cTotalCols - 1;
for (i = m_cTotalCols - 1; i >= 0; i--)
if (m_aIndex [i] == -1)
DeleteColumn (i);
int aOrder [LISTEX_MAXCOLUMNS];
int iCorr = 0;
for (i = 0; i < m_cTotalCols; i++)
{
if (m_aIndex [i] != -1)
aOrder [m_aIndex [i]] = i - iCorr;
else
iCorr ++;
}
pHdr->SetOrderArray (GetHeaderCtrl ()->GetItemCount (), (int*) aOrder);
RebuildAIndex ();
for (i = 0; i < m_cTotalCols; i++)
{
if (piWidthes [i] > 0)
SetColumnWidth (aOrder [m_aIndex [i]], piWidthes [i]);
}
delete [] pbW;
delete [] pbI;
}
}
示例8: GetHeaderCtrl
void CIrcNickListCtrl::Localize()
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
CString sResource;
sResource = GetResString(IDS_STATUS);
HDITEM hdi;
hdi.pszText = const_cast<LPTSTR>((LPCTSTR)sResource);
hdi.mask = HDI_TEXT;
pHeaderCtrl->SetItem(1, &hdi);
UpdateNickCount();
}
示例9: GetHeaderCtrl
int CColListCtrl::SetComboBoxColumn( int nCol )
{
CHeaderCtrl * pHeaderCtrl = GetHeaderCtrl();
if( pHeaderCtrl )
{
ASSERT( nCol < pHeaderCtrl->GetItemCount() );
}
m_nComboBoxColumn = nCol;
return m_nComboBoxColumn;
}
示例10: ASSERT
BOOL CSHListCtrl::PositionControl(CWnd * pWnd, int iItem, int iSubItem)
{
ASSERT( pWnd && pWnd->m_hWnd );
ASSERT( iItem >= 0 );
// Make sure that the item is visible
if (!EnsureVisible(iItem, TRUE))
return NULL;
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
ASSERT(iSubItem >= 0 && iSubItem < nColumnCount);
if (iSubItem >= nColumnCount ||
// We have to take into account that the header may be reordered
GetColumnWidth(Header_OrderToIndex( pHeader->m_hWnd, iSubItem)) < 5)
{
return 0;
}
// Get the header order array to sum the column widths up to the selected cell.
int *orderarray = new int[nColumnCount];
Header_GetOrderArray(pHeader->m_hWnd, nColumnCount, orderarray);
int offset = 0;
int i;
for (i = 0; orderarray[i] != iSubItem; i++)
offset += GetColumnWidth(orderarray[i]);
int colwidth = GetColumnWidth(iSubItem);
delete[] orderarray;
CRect rect;
GetItemRect(iItem, &rect, LVIR_BOUNDS);
// Scroll if we need to expose the column
CRect rcClient;
GetClientRect(&rcClient);
if (offset + rect.left < 0 || offset + colwidth + rect.left > rcClient.right)
{
CSize size;
size.cx = offset + rect.left;
size.cy = 0;
Scroll( size );
rect.left -= size.cx;
}
rect.left += offset + 4;
rect.right = rect.left + colwidth - 3;
// The right end of the control should not go past the edge
// of the grid control.
if (rect.right > rcClient.right)
rect.right = rcClient.right;
pWnd->MoveWindow(&rect);
return 1;
}
示例11: SetHeaderParam
// 设置/获取某列Header的参数
void CLogViewDlg::SetHeaderParam(int nIndex, LPARAM lParam)
{
CHeaderCtrl* pHeader = m_LogList.GetHeaderCtrl();
if(pHeader != NULL)
{
HDITEM hdItem = {0};
hdItem.mask = HDI_LPARAM;
hdItem.lParam = lParam;
pHeader->SetItem(nIndex, &hdItem);
}
}
示例12: InsertMenu
void InsertMenu(CListCtrl& list,
CMenu* pMenu,
UINT nIndex, // Menu id to remplace
CImageList* pImageList)
{
CHeaderCtrl *pHeader = list.GetHeaderCtrl();
int nbCol = pHeader->GetItemCount();
int nAfter = -1, id;
char buffer[maxTitleLength];
HDITEM hi;
if (pImageList == NULL) pImageList = pHeader->GetImageList();
hi.mask = HDI_FORMAT|HDI_IMAGE|HDI_LPARAM|HDI_TEXT;
hi.pszText = buffer;
hi.cchTextMax = maxTitleLength;
while (--nbCol >= 0) {
pHeader->GetItem(nbCol, &hi);
if (hi.lParam == 0) continue;
// there is a sort possible column
id = nIndex + nbCol;
if (nAfter < 0) {
if (!pMenu->ModifyMenu(nIndex, MF_BYCOMMAND|MF_STRING, id, buffer))
return;
} else {
pMenu->InsertMenu(nAfter, MF_BYCOMMAND|MF_STRING, id, buffer);
}
if (hi.iImage && pImageList) {
static CBitmap bm, *pOldBm;
IMAGEINFO ii;
CDC dcMem;
// fill a bitmap with the sort image
pImageList->GetImageInfo(hi.iImage, &ii);
int w = ii.rcImage.right - ii.rcImage.left;
int h = ii.rcImage.bottom - ii.rcImage.top;
dcMem.CreateCompatibleDC(NULL);
if (bm.m_hObject) bm.DeleteObject();
bm.CreateCompatibleBitmap(&dcMem, w, h);
pOldBm = dcMem.SelectObject(&bm);
dcMem.FillSolidRect(0, 0, w, h, 0xFFFFFF);
pImageList->Draw(&dcMem, hi.iImage, CPoint(0,0), ILD_NORMAL);
dcMem.SelectObject(pOldBm);
// display the sort icon
pMenu->SetMenuItemBitmaps(id, MF_BYCOMMAND, &bm, &bm);
}
nAfter = id;
}
}
示例13: GetCurrentMessage
//***************************************************************
void CColorListCtrl::OnPaint()
{
// First let the control do its default drawing.
const MSG *msg = GetCurrentMessage();
DefWindowProc( msg->message, msg->wParam, msg->lParam );
if (!m_fullColumnLines) return;
// Draw the lines only for LVS_REPORT mode
if( (GetStyle() & LVS_TYPEMASK) == LVS_REPORT )
{
// Get the number of columns
CClientDC dc(this );
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// The bottom of the header corresponds to the top of the line
RECT rect;
pHeader->GetClientRect( &rect );
int top = rect.bottom;
// Now get the client rect so we know the line length and
// when to stop
GetClientRect( &rect );
// The border of the column is offset by the horz scroll
int borderx = 0 - GetScrollPos( SB_HORZ );
CPen *pOldPen;
CPen pen;
CGdiObject *pOldBrush;
pen.CreatePen( PS_DOT, 0, GetColorRef(DEF_DESELTEXT) );
pOldPen =dc.SelectObject(&pen);
pOldBrush=dc.SelectStockObject(NULL_BRUSH);
for( int i = 0; i < nColumnCount; i++ )
{
// Get the next border
borderx += GetColumnWidth( i );
// if next border is outside client area, break out
if( borderx >= rect.right ) break;
// Draw the line.
dc.MoveTo( borderx-1, top);
dc.LineTo( borderx-1, rect.bottom );
}
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
}
// Do not call CListCtrl::OnPaint() for painting messages
}
示例14: GetHeaderParam
LPARAM CLogViewDlg::GetHeaderParam(int nIndex)
{
CHeaderCtrl* pHeader = m_LogList.GetHeaderCtrl();
if(pHeader != NULL)
{
HDITEM hdItem = {0};
hdItem.mask = HDI_LPARAM;
pHeader->GetItem(nIndex, &hdItem);
return hdItem.lParam;
}
return 0;
}
示例15: GetListCtrl
void CTblInfoView::SetSelResults(const char *pszRet)
{
//update local cache
m_map_req_resp[m_strQueryReq] = pszRet;
//make sure m_strCurTbl matches the results.
//so, OP_SUBMITTING is added
static CMainFrame* pMainFrame = reinterpret_cast<CMainFrame*>(AfxGetMainWnd());
static CListCtrl &ctrl = GetListCtrl();
CHeaderCtrl *pHeader = ctrl.GetHeaderCtrl();
int nCount = pHeader->GetItemCount();
ctrl.DeleteAllItems();
CString strCols = pszRet;
CString strSub = _T("");
int nItem = 0;
int nSubItem = 0;
int nIndex = 0;
LVITEM lv;
lv.mask = LVIF_TEXT;
for (int i = 0; ; i++)
{
if (!AfxExtractSubString(strSub, strCols, i, '|')
|| 0 == strSub.GetLength())
{
break;
}
nItem = i / nCount;
nSubItem = i % nCount;
lv.iItem = nIndex;//0; //nItem;
lv.iSubItem = nSubItem;
lv.pszText = strSub.GetBuffer(0);
if (0 == nSubItem)
{
nIndex = ctrl.InsertItem(&lv);
}
else
{
ctrl.SetItem(&lv);
}
}
m_Operation = OP_NONE;
}