本文整理汇总了C++中CHeaderCtrl::GetItemCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CHeaderCtrl::GetItemCount方法的具体用法?C++ CHeaderCtrl::GetItemCount怎么用?C++ CHeaderCtrl::GetItemCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHeaderCtrl
的用法示例。
在下文中一共展示了CHeaderCtrl::GetItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowEdit
////////////////////////////////////////////////////////////////
//进入编辑状态
//IN : BOOL bShow 是否显示
// int nItem 行号
// int nIndex 列号
// DWORD dwAddStyle 新增类型
void CListCtrlEditBase::ShowEdit(int nItem,int nSubItem)
////////////////////////////////////////////////////////////////
{
if (nItem < 0 || nSubItem < 0) return;
if (m_pParentList == NULL) return ;
if (m_pInEdit == NULL) return ;
CRect rect;
// m_pParentList = pCtrl;
// m_pParentList->GetSubItemRect(nItem,nIndex,LVIR_LABEL,rcCtrl);
// 列可见
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_pParentList->GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if( nSubItem >= nColumnCount || m_pParentList->GetColumnWidth(nSubItem) < 5 )
return ;
// 列偏移
int offset = 0;
for( int i = 0; i < nSubItem; i++ )
offset += m_pParentList->GetColumnWidth( i );
m_pParentList->GetItemRect( nItem, &rect, LVIR_BOUNDS );
// 滚动列,便于操作
CRect rcClient;
m_pParentList->GetClientRect( &rcClient );
if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
{
CSize size;
size.cx = offset + rect.left;
size.cy = 0;
m_pParentList->Scroll( size );
rect.left -= size.cx;
}
// 获取列的对齐方式
LV_COLUMN lvcol;
lvcol.mask = LVCF_FMT;
m_pParentList->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;
rect.right = rect.left + m_pParentList->GetColumnWidth( nSubItem );// - 20;
if( rect.right > rcClient.right) rect.right = rcClient.right;
// rect.top += 2;
//rect.bottom = rect.top + 12 * rect.Height();
CString strItem = m_pParentList->GetItemText(nItem,nSubItem);
m_pParentList->ClientToScreen(rect);
m_pInEdit->GetParent()->ScreenToClient(rect);
m_pInEdit->MoveWindow(rect);
// SetWindowPos(NULL, rect.left,rect.top,rect.Width(),rect.Height(), SWP_SHOWWINDOW);
m_pInEdit->ShowWindow(SW_SHOW);
m_pInEdit->SetWindowText(strItem);
::SetFocus(m_pInEdit->GetSafeHwnd());
// ((CEdit *)m_pInEdit)->SetSel(0,-1);
SendMessage(m_pInEdit->GetSafeHwnd(), EM_SETSEL, 0, -1);
m_nCurrentItem = nItem;
m_nCurrentSubItem = nSubItem;
}
示例2: DrawItem
void CClientListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if( !theApp.emuledlg->IsRunning() )
return;
if (!lpDrawItemStruct->itemData)
return;
CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC);
BOOL bCtrlFocused = ((GetFocus() == this ) || (GetStyle() & LVS_SHOWSELALWAYS));
if (lpDrawItemStruct->itemState & ODS_SELECTED) {
if(bCtrlFocused)
odc->SetBkColor(m_crHighlight);
else
odc->SetBkColor(m_crNoHighlight);
}
else
odc->SetBkColor(GetBkColor());
const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData;
CMemDC dc(odc, &lpDrawItemStruct->rcItem);
CFont* pOldFont = dc.SelectObject(GetFont());
CRect cur_rec(lpDrawItemStruct->rcItem);
COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText);
int iOldBkMode;
if (m_crWindowTextBk == CLR_NONE){
DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0);
iOldBkMode = dc.SetBkMode(TRANSPARENT);
}
else
iOldBkMode = OPAQUE;
CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
int iCount = pHeaderCtrl->GetItemCount();
cur_rec.right = cur_rec.left - 8;
cur_rec.left += 4;
CString Sbuffer;
for(int iCurrent = 0; iCurrent < iCount; iCurrent++){
int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
if( !IsColumnHidden(iColumn) ){
cur_rec.right += GetColumnWidth(iColumn);
switch(iColumn){
case 0:{
uint8 image;
if (client->IsFriend())
image = 2;
else if (client->GetClientSoft() == SO_EDONKEYHYBRID)
image = 4;
else if (client->GetClientSoft() == SO_MLDONKEY)
image = 3;
else if (client->GetClientSoft() == SO_SHAREAZA)
image = 5;
else if (client->GetClientSoft() == SO_URL)
image = 6;
else if (client->GetClientSoft() == SO_AMULE)
image = 7;
else if (client->GetClientSoft() == SO_LPHANT)
image = 8;
else if (client->ExtProtocolAvailable())
//==>Modversion [shadow2004]
#ifdef MODVERSION
image = (client->IsNextEMF())?10:1;
#else //Modversion
image = 1;
#endif //Modversion
//<==Modversion [shadow2004]
else
image = 0;
POINT point = {cur_rec.left, cur_rec.top+1};
imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0));
if (client->GetUserName()==NULL)
Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN));
else
Sbuffer = client->GetUserName();
cur_rec.left +=20;
dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
cur_rec.left -=20;
break;
}
case 1:{
Sbuffer = client->GetUploadStateDisplayString();
break;
}
case 2:{
if(client->credits)
Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false);
else
Sbuffer.Empty();
break;
}
case 3:{
Sbuffer = client->GetDownloadStateDisplayString();
break;
}
case 4:{
if(client->credits)
Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false);
else
Sbuffer.Empty();
break;
}
//.........这里部分代码省略.........
示例3: HitTestEx
// **************************************************************************
// HitTestEx ()
//
// Description:
// Determine which item or subitem was hit.
//
// Parameters:
// CPoint &cPoint Current locaction of mouse cursor
// int *pCol Gets set to column hit was in.
//
// Returns:
// int - Row hit was in, or -1 if hit was not on a cell.
// **************************************************************************
int CKListEditCtrl::HitTestEx (CPoint &cPoint, int *pCol)
{
int nCol = 0;
int nRow = HitTest (cPoint, NULL);
int nBottom = 0;
int cnColumns = 0;
// Initialize returned column number to zero:
if (pCol)
*pCol = 0;
// Make sure that the ListView is in LVS_REPORT format:
if ((GetWindowLong (m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
return (nRow);
// Get the top and bottom visible rows:
nRow = GetTopIndex ();
nBottom = nRow + GetCountPerPage ();
// Make sure bottom index is valid:
if (nBottom > GetItemCount ())
nBottom = GetItemCount ();
// Get the number of columns:
CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0);
cnColumns = pHeader->GetItemCount ();
// Determine which row the hit occurred:
for (; nRow <= nBottom; nRow++)
{
// Get bounding rect of item:
CRect rect;
GetItemRect (nRow, &rect, LVIR_BOUNDS);
// Check to see if the point falls in bounds of that row:
if (rect.PtInRect (cPoint))
{
// Hit was in this row. Now find the column:
for (nCol = 0; nCol < cnColumns; nCol++)
{
int nColWidth = GetColumnWidth (nCol);
// If hit is within this column, return:
if (cPoint.x >= rect.left && cPoint.x <= (rect.left + nColWidth))
{
if (pCol)
*pCol = nCol;
return (nRow);
}
// Adjust left side of row's rectangle so we will look at
// next column ntext time around loop:
rect.left += nColWidth;
}
}
}
// If we make it here, then the hit was not on a cell. Return -1
// to indicate failure:
return (-1);
}
示例4: if
CEdit*
CListCtrlEx::EditSubItem (int Item, int Column)
{
// The returned pointer should not be saved
CancelEdit(FALSE);
// Make sure that the item is visible
if (!EnsureVisible (Item, TRUE))
{
InsertItemEx (Item);
if (!EnsureVisible (Item, TRUE))
return NULL;
}
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if (Column >= nColumnCount || GetColumnWidth (Column) < 5)
return NULL;
// Get the column offset
int Offset = 0;
for (int iColumn = 0; iColumn < Column; iColumn++)
Offset += GetColumnWidth (iColumn);
CRect Rect;
GetItemRect (Item, &Rect, LVIR_BOUNDS);
// Now scroll if we need to expose the column
CRect ClientRect;
GetClientRect (&ClientRect);
if (Offset + Rect.left < 0 || Offset + Rect.left > ClientRect.right)
{
CSize Size;
if (Offset + Rect.left > 0)
Size.cx = -(Offset - Rect.left);
else
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 (Column, &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 (Column) - 3;
if (Rect.right > ClientRect.right)
Rect.right = ClientRect.right;
dwStyle |= WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
// Send Notification to parent of ListView ctrl
LV_DISPINFO dispinfo;
dispinfo.hdr.hwndFrom = m_hWnd;
dispinfo.hdr.idFrom = 0;
dispinfo.hdr.code = LVN_BEGINLABELEDIT;
dispinfo.item.mask = LVIF_TEXT;
dispinfo.item.iItem = Item;
dispinfo.item.iSubItem = Column;
dispinfo.item.pszText = NULL;
dispinfo.item.cchTextMax = 0;
// Return Values
// To allow the user to edit the label, return FALSE.
// To prevent the user from editing the label, return TRUE.
if (!GetParent()->SendMessage (WM_NOTIFY, GetDlgCtrlID(), (LPARAM) &dispinfo)) {
CEditCell *pEdit = new CEditCell (this, Item, Column, GetItemText(Item, Column),
m_AutoComplete.GetCount() > 0 ? &m_AutoComplete : NULL);
pEdit->Create (dwStyle, Rect, this, IDC_EDITCELL);
return pEdit;
} else {
return NULL;
}
}
示例5: Localize
void CQueueListCtrl::Localize()
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
HDITEM hdi;
hdi.mask = HDI_TEXT;
if(pHeaderCtrl->GetItemCount() != 0) {
CString strRes;
strRes = GetResString(IDS_QL_USERNAME);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(0, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_FILE);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(1, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_FILEPRIO);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(2, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_QL_RATING);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(3, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_SCORE);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(4, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_ASKED);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(5, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_LASTSEEN);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(6, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_ENTERQUEUE);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(7, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_BANNED);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(8, &hdi);
strRes.ReleaseBuffer();
strRes = GetResString(IDS_UPSTATUS);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(9, &hdi);
strRes.ReleaseBuffer();
//==>Modversion [shadow2004]
#ifdef MODVERSION
strRes = GetResString(IDS_CLIENTSOFTWARE);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(10, &hdi);
strRes.ReleaseBuffer();
#endif //Modversion
//<==Modversion [shadow2004]
}
}
示例6: DrawItem
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (!theApp.emuledlg->IsRunning())
return;
if (!lpDrawItemStruct->itemData)
return;
CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC);
BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS));
if (lpDrawItemStruct->itemState & ODS_SELECTED) {
if (bCtrlFocused)
odc->SetBkColor(m_crHighlight);
else
odc->SetBkColor(m_crNoHighlight);
}
else
odc->SetBkColor(GetBkColor());
const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData;
CMemDC dc(odc, &lpDrawItemStruct->rcItem);
CFont* pOldFont = dc.SelectObject(GetFont());
CRect cur_rec(lpDrawItemStruct->rcItem);
COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText);
if (client->GetSlotNumber() > theApp.uploadqueue->GetActiveUploadsCount()) {
dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
int iOldBkMode;
if (m_crWindowTextBk == CLR_NONE){
DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0);
iOldBkMode = dc.SetBkMode(TRANSPARENT);
}
else
iOldBkMode = OPAQUE;
CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
int iCount = pHeaderCtrl->GetItemCount();
cur_rec.right = cur_rec.left - 8;
cur_rec.left += 4;
CString Sbuffer;
for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
{
int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
if (!IsColumnHidden(iColumn))
{
cur_rec.right += GetColumnWidth(iColumn);
switch (iColumn)
{
case 0:{
uint8 image;
if (client->IsFriend())
image = 4;
else if (client->GetClientSoft() == SO_EDONKEYHYBRID){
if (client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 8;
else
image = 7;
}
else if (client->GetClientSoft() == SO_MLDONKEY){
if (client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 6;
else
image = 5;
}
else if (client->GetClientSoft() == SO_SHAREAZA){
if(client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 10;
else
image = 9;
}
else if (client->GetClientSoft() == SO_AMULE){
if(client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 12;
else
image = 11;
}
else if (client->GetClientSoft() == SO_LPHANT){
if(client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 14;
else
image = 13;
}
else if (client->ExtProtocolAvailable()){
if(client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 3;
else
image = 1;
}
else{
if (client->credits->GetScoreRatio(client->GetIP()) > 1)
image = 2;
else
image = 0;
}
POINT point = {cur_rec.left, cur_rec.top+1};
imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0));
Sbuffer = client->GetUserName();
cur_rec.left += 20;
dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT);
cur_rec.left -= 20;
//.........这里部分代码省略.........
示例7: OnClickList
void CBlockProperties::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
{
float distance;
char nodeName[NODES_ABBRNAME_LENGTH + 1];
long deadheadTime;
int rcode2;
int pos;
POSITION position = pListCtrlLIST->GetFirstSelectedItemPosition();
//
// Determine the selection(s)
//
if(position == NULL)
{
return;
}
//
// Display the trip
//
LVCOLUMN LVC;
int nItem = pListCtrlLIST->GetNextSelectedItem(position);
int nI = pListCtrlLIST->GetItemData(nItem);
//
// Get the trip
//
TRIPSKey0.recordID = m_pRELIEFPOINTS[nI].TRIPSrecordID;
btrieve(B_GETEQUAL, TMS_TRIPS, &TRIPS, &TRIPSKey0, 0);
//
// Show the route, service, direction, and pattern
//
char routeNumberAndName[ROUTES_NUMBER_LENGTH + 3 + ROUTES_NAME_LENGTH + 1];
char serviceName[SERVICES_NAME_LENGTH + 1];
char directionName[DIRECTIONS_LONGNAME_LENGTH + 1];
char patternName[PATTERNNAMES_NAME_LENGTH + 1];
ROUTESKey0.recordID = TRIPS.ROUTESrecordID;
btrieve(B_GETEQUAL, TMS_ROUTES, &ROUTES, &ROUTESKey0, 0);
strncpy(routeNumberAndName, ROUTES.number, ROUTES_NUMBER_LENGTH);
trim(routeNumberAndName, ROUTES_NUMBER_LENGTH);
strcat(routeNumberAndName, " - ");
strncpy(tempString, ROUTES.name, ROUTES_NAME_LENGTH);
trim(tempString, ROUTES_NAME_LENGTH);
strcat(routeNumberAndName, tempString);
SERVICESKey0.recordID = TRIPS.SERVICESrecordID;
btrieve(B_GETEQUAL, TMS_SERVICES, &SERVICES, &SERVICESKey0, 0);
strncpy(serviceName, SERVICES.name, SERVICES_NAME_LENGTH);
trim(serviceName, SERVICES_NAME_LENGTH);
DIRECTIONSKey0.recordID = ROUTES.DIRECTIONSrecordID[TRIPS.directionIndex];
btrieve(B_GETEQUAL, TMS_DIRECTIONS, &DIRECTIONS, &DIRECTIONSKey0, 0);
strncpy(directionName, DIRECTIONS.longName, DIRECTIONS_LONGNAME_LENGTH);
trim(directionName, DIRECTIONS_LONGNAME_LENGTH);
PATTERNNAMESKey0.recordID = TRIPS.PATTERNNAMESrecordID;
btrieve(B_GETEQUAL, TMS_PATTERNNAMES, &PATTERNNAMES, &PATTERNNAMESKey0, 0);
strncpy(patternName, PATTERNNAMES.name, PATTERNNAMES_NAME_LENGTH);
trim(patternName, PATTERNNAMES_NAME_LENGTH);
sprintf(tempString, "Trip info: %s %s %s on pattern %s",
serviceName, directionName, routeNumberAndName, patternName);
pStaticTRIPINFO->SetWindowText(tempString);
//
// Clear out the previous ListCtrl
//
pListCtrlTRIPDATA->DeleteAllItems();
CHeaderCtrl* pCtrl = pListCtrlTRIPDATA->GetHeaderCtrl();
if(pCtrl != NULL)
{
int nCount = pCtrl->GetItemCount();
for(nI = 0; nI < nCount; nI++)
{
pCtrl->DeleteItem(0);
}
}
//
// Set up the list control
//
GenerateTripDef GTResults;
GetConnectionTimeDef GCTData;
int numNodes = GenerateTrip(TRIPS.ROUTESrecordID, TRIPS.SERVICESrecordID,
TRIPS.directionIndex, TRIPS.PATTERNNAMESrecordID,
TRIPS.timeAtMLP, GENERATETRIP_FLAG_DISPLAYERRORS, >Results);
pos = 0;
//
// Is this a pullout?
//
long POTime = NO_TIME;
if(TRIPS.standard.POGNODESrecordID != NO_RECORD)
{
GCTData.fromPATTERNNAMESrecordID = TRIPS.PATTERNNAMESrecordID;
GCTData.toPATTERNNAMESrecordID = TRIPS.PATTERNNAMESrecordID;
GCTData.fromROUTESrecordID = TRIPS.ROUTESrecordID;
GCTData.fromSERVICESrecordID = TRIPS.SERVICESrecordID;
//.........这里部分代码省略.........
示例8: riga
/*
HitTestEx()
Ricava la riga (HitTest()) e la colonna a cui e' stato effettuato il click.
*/
int CListViewEx::HitTestEx(CPoint &point, int *col) const
{
int colnum = 0;
int row = GetListCtrl().HitTest( point, NULL );
if(col) *col = -1; // 0;
// Make sure that the ListView is in LVS_REPORT
if((GetWindowLong(m_hWnd,GWL_STYLE) & LVS_TYPEMASK)!=LVS_REPORT)
return row;
// Get the top and bottom row visible
row = GetListCtrl().GetTopIndex();
int bottom = row + GetListCtrl().GetCountPerPage();
if(bottom > GetListCtrl().GetItemCount())
bottom = GetListCtrl().GetItemCount();
// BUGFIX : when columns are moved
// When user change column's order by dragging header Control, original code has some bug.
// Edit Box is not show at correct position or HitTestEx return incoreect column number.
#if 0
// Get the number of columns
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// Loop through the visible rows
for( ;row <=bottom;row++)
{
// Get bounding rect of item and check whether point falls in it.
CRect rect;
GetListCtrl().GetItemRect(row,&rect,LVIR_BOUNDS);
if(rect.PtInRect(point))
{
// Now find the column
for(colnum = 0; colnum < nColumnCount; colnum++)
{
int colwidth = GetListCtrl().GetColumnWidth(colnum);
if(point.x >= rect.left && point.x <= (rect.left + colwidth))
{
if(col) *col = colnum;
return row;
}
rect.left += colwidth;
}
}
}
return -1;
#else
// Get the number of columns
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// Loop through the visible rows
// Array of Column prder by Sang-il, Lee
INT* piColumnArray = new INT[nColumnCount];
((CListCtrl*)this)->GetColumnOrderArray(piColumnArray);
for( ;row <=bottom;row++)
{
// Get bounding rect of item and check whether point falls in it.
CRect rect;
GetListCtrl().GetItemRect(row,&rect,LVIR_BOUNDS);
if(rect.PtInRect(point))
{
// Now find the column
for(colnum = 0; colnum < nColumnCount; colnum++)
{
int colwidth = GetListCtrl().GetColumnWidth(piColumnArray[colnum]);
if( point.x >= rect.left && point.x <= (rect.left + colwidth))
{
if(col) *col = piColumnArray[colnum];
TRACE("HitTestEx() col=%d\n",*col);
delete [] piColumnArray;
return row;
}
rect.left += colwidth;
}
}
}
delete [] piColumnArray;
return -1;
#endif
}
示例9: OnSubmit
void CTblInfoView::OnSubmit()
{
if (OP_NONE == m_Operation)
{
AfxMessageBox("尚未选择有关操作");
return;
}
static CMainFrame *pMainFrame = reinterpret_cast<CMainFrame*>(AfxGetMainWnd());
static CNetWork *pNet = &pMainFrame->m_Nets;
//获取相关字段
static CListCtrl &ctrl = GetListCtrl();
int nItem = ctrl.GetSelectionMark();
if (-1 == nItem)
{
return;
}
//获取头部相关信息
CHeaderCtrl *pHeader = ctrl.GetHeaderCtrl();
int nCount = pHeader->GetItemCount();
TCHAR szBuffer[MAXBYTE];
HDITEM hdi;
hdi.mask = HDI_TEXT;
hdi.pszText = szBuffer;
hdi.cchTextMax = MAXBYTE;
CString strSub;
CString strCol;
CString strInfo = "";
int i = 0;
int j = 0;
for (i = 0; i < nCount; i++)
{
strSub = ctrl.GetItemText(nItem, i);
if (0 == strSub.Compare(PAD)
|| 0 == strSub.GetLength())
{
continue;
}
j++; //非空字段
pHeader->GetItem(i, &hdi);
strCol = hdi.pszText;
//alias process
strInfo += pNet->GetOriName(strCol);
strInfo += SEP;
strInfo += strSub;
strInfo += SEP;
}
//check
if ((INFO_TYPE_INSERT == m_Operation
|| INFO_TYPE_UPDATE == m_Operation
)
&& j < nCount - 1)
{
AfxMessageBox("字段不完整,无法操作");
return;
}
if (m_pCurReq != NULL)
{
delete m_pCurReq;
m_pCurReq = NULL;
}
//将字段、数据、动作信息发给M Server
m_pCurReq = new CRequest(m_Operation, m_strCurTbl, strInfo);
if (NULL == m_pCurReq)
{
//sth wrong
m_Operation = OP_NONE;
return;
}
//未从本地缓存查询到结果,或者非查询操作,直接转交M Server处理
if (!QueryLocalCache(m_pCurReq))
{
pNet->SendRequest(m_pCurReq);
}
m_Operation = OP_SUBMITTING;
}
示例10: GetColumnCount
/*
GetColumnCount()
Ricava il numero di colonne del controllo.
*/
int CListViewEx::GetColumnCount()
{
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetListCtrl().GetDlgItem(0);
return(pHeader ? pHeader->GetItemCount() : 0);
}
示例11: EditSubLabel
CEdit* CListViewEx::EditSubLabel(int nRow,int nCol)
{
// Make sure that nRow is visible
if(!GetListCtrl().EnsureVisible(nRow,TRUE))
return(NULL);
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if(nCol >= nColumnCount || GetListCtrl().GetColumnWidth(nCol) < 5)
return(NULL);
// BUGFIX : when columns are moved
// When user change column's order by dragging header Control, original code has some bug.
// Edit Box is not show at correct position or HitTestEx return incoreect column number.
#if 0
// Get the column offset
int offset = 0;
for(int i=0; i < nCol; i++)
offset += GetListCtrl().GetColumnWidth(i);
#else
// Get the column offset
int offset = 0;
// Array of Column prder by Sang-il, Lee
INT *piColumnArray = new INT[nColumnCount];
GetListCtrl().GetColumnOrderArray(piColumnArray);
for(int i=0; nCol!=piColumnArray[i]; i++)
offset += GetListCtrl().GetColumnWidth(piColumnArray[i]);
// delete Array
delete [] piColumnArray;
#endif
// ENDBUGFIX
CRect rect;
GetListCtrl().GetItemRect(nRow,&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;
GetListCtrl().Scroll(size);
rect.left -= size.cx;
}
rect.left += offset + 4;
rect.right = rect.left + GetListCtrl().GetColumnWidth(nCol) - 3;
if(rect.right > rcClient.right)
rect.right = rcClient.right;
// Get Column alignment
LV_COLUMN lvcol = {0};
lvcol.mask = LVCF_FMT;
GetListCtrl().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;
dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
CEdit *pEdit = new CInPlaceEdit(nRow,nCol,GetListCtrl().GetItemText(nRow,nCol));
if(pEdit)
pEdit->Create(dwStyle,rect,this,IDC_IN_PLACE_EDIT);
return(pEdit);
}
示例12: ColumnSort
int ColumnSort(CListCtrl& list,
int iSubItem, // column number (0..n-1) or -1=> last column
UINT state) // CS_SORT : sort in the same order
// CS_REVERSE : sort reverse
// CS_FOR, CS_BACK : sort command
// CS_SELVIS : 0=> show the selected item
{ // CS_SORTICON : icon display
CHeaderCtrl *pHeader = list.GetHeaderCtrl();
int ix = pHeader->GetItemCount();
HDITEM hi;
if (iSubItem >= ix) iSubItem = -1;
// search the old sorted column
hi.mask = HDI_IMAGE|HDI_FORMAT|HDI_LPARAM;
while (--ix >= 0) {
pHeader->GetItem(ix, &hi);
if (hi.iImage == 0) continue;
if (iSubItem >= 0 && ix != iSubItem) {
// delete old display icon
hi.iImage = 0;
// hi.lParam |= STI_REVERSE; // *******************
hi.fmt &= ~HDF_IMAGE;
pHeader->SetItem(ix, &hi);
}
break;
}
if (iSubItem < 0) {
if (ix < 0) return -3; // a sorted column is not define
iSubItem = ix; // there is the old column
}
// set the new display icon
pHeader->GetItem(iSubItem, &hi);
if (hi.lParam == 0) return -2; // sort disable for this column
switch (state & 0x0003) {
case CS_SORT : break; // in the same order
case CS_REVERSE: hi.lParam ^= 1; break; // in the revers order
case CS_ASCEND : hi.lParam &= ~1; break; // to impose ascending order
case CS_DESCEND: hi.lParam |= 1; break; // to inpose descending order
}
hi.iImage = hi.lParam;
if (state & CS_SORTICON) hi.fmt |= HDF_IMAGE; // the icon
pHeader->SetItem(iSubItem, &hi);
SortTextItems(list, iSubItem, short(hi.lParam));
if ((state & CS_SELVISIBLE) == 0) {
// Make that the selected item continue to stay visible
POSITION pos = list.GetFirstSelectedItemPosition();
if (pos) {
// search the seleted item
int no = list.GetNextSelectedItem(pos);
list.EnsureVisible(no, FALSE);
return no; // selected item
}
}
return -1;
}
示例13: DrawItem
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
#define LIST_CELL_PADDING 6 //should be even number
if (!g_App.m_pMDlg->IsRunning() || !lpDrawItemStruct->itemData)
return;
CDC *odc = CDC::FromHandle(lpDrawItemStruct->hDC);
BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS));
COLORREF crBk, crWinBk;
crWinBk = crBk = GetBkColor();
if (lpDrawItemStruct->itemState & ODS_SELECTED)
crBk = (bCtrlFocused) ? m_crHighlight : m_crNoHighlight;
CUpDownClient *pClient = reinterpret_cast<CUpDownClient*>(lpDrawItemStruct->itemData);
CMemDC dc(odc, &lpDrawItemStruct->rcItem, crWinBk, crBk);
CFont *pOldFont = dc.SelectObject(GetFont());
COLORREF crOldTextColor = dc->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
int iWidth, iColumn;
bool bMeasuring = (m_iMeasuringColumn >= 0);
UINT iCalcFlag = bMeasuring ? (DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|DT_NOCLIP|DT_CALCRECT) : (DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS);
if (IsRightToLeftLanguage())
iCalcFlag |= DT_RTLREADING;
RECT r = lpDrawItemStruct->rcItem;
CString strBuffer;
CKnownFile *pKnownFile = g_App.m_pSharedFilesList->GetFileByID(pClient->m_reqFileHash);
CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
int iNumColumns = pHeaderCtrl->GetItemCount();
r.right = r.left - LIST_CELL_PADDING / 2;
r.left += LIST_CELL_PADDING / 2;
iWidth = LIST_CELL_PADDING;
for (int iCurrent = 0; iCurrent < iNumColumns; iCurrent++)
{
iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
if (IsColumnHidden(iColumn) || (bMeasuring && iColumn != m_iMeasuringColumn))
continue;
r.right += CListCtrl::GetColumnWidth(iColumn);
switch (iColumn)
{
case QLCOL_USERNAME:
{
if (!bMeasuring)
{
POINT point = {r.left, r.top + 1};
int iImgLstIdx = CLIENT_IMGLST_PLAIN;
// Select corresponding image list depending on client properties
if (pClient->IsBanned())
iImgLstIdx = CLIENT_IMGLST_BANNED;
else if (pClient->IsFriend())
iImgLstIdx = CLIENT_IMGLST_FRIEND;
else if (pClient->m_pCredits->HasHigherScoreRatio(pClient->GetIP()))
iImgLstIdx = CLIENT_IMGLST_CREDITUP;
// Display Client icon
g_App.m_pMDlg->m_clientImgLists[iImgLstIdx].Draw(dc, pClient->GetClientIconIndex(), point, ILD_NORMAL);
r.left += 20;
if (g_App.m_pIP2Country->ShowCountryFlag())
{
point.x += 20;
point.y += 2;
g_App.m_pIP2Country->GetFlagImageList()->Draw(dc, pClient->GetCountryIndex(), point, ILD_NORMAL);
r.left += 22;
}
}
else
{
iWidth += 20;
if (g_App.m_pIP2Country->ShowCountryFlag())
iWidth += 22;
}
strBuffer = pClient->GetUserName();
break;
}
case QLCOL_FILENAME:
if (pKnownFile)
strBuffer = pKnownFile->GetFileName();
else
strBuffer = _T("?");
break;
case QLCOL_FILEPRIORITY:
{
if (pKnownFile)
{
UINT dwResStrId;
switch (pKnownFile->GetULPriority())
{
case PR_RELEASE:
dwResStrId = IDS_PRIORELEASE;
break;
//.........这里部分代码省略.........
示例14: Key_Shift
BOOL CListCtrlEditBase::Key_Shift(int& nItem,int& nSub)
{
if(!m_pParentList) return FALSE;
int nItemCount = m_pParentList->GetItemCount();
// DWORD dwData = m_dwData;
// nItem= dwData>>16;
// nSub = dwData&0x0000ffff;
int iOp = 1;
nItem= m_nCurrentItem;
nSub = m_nCurrentSubItem;
CWnd *pWnd;
CHeaderCtrl* pHeader = m_pParentList->GetHeaderCtrl();
if(pHeader == NULL)
return FALSE;
short sRet = GetKeyState(VK_SHIFT);
int nSubcCount = pHeader->GetItemCount();
sRet = sRet >>15;
if(sRet == 0) //TAB
{
for(;;)
{
nSub += 1;
if(nSub >= nSubcCount) //列末
{
if(nItem == nItemCount-1) //行末
{
//nItem = 0;
//nSub = 0;
nItem= m_nCurrentItem;
nSub = m_nCurrentSubItem;
return FALSE;
}
else //移下一行
{
nSub = 0;
nItem += 1;
}
}
pWnd = m_CtrlMap.GetSubWnd(m_pParentList, nSub);
if (pWnd )
{
pWnd->PostMessage(WM_USER_SHOW_EDIT, nItem, nSub);
//pWnd->SendMessage(WM_USER_SHOW_EDIT, nItem, nSub);
return TRUE;
}
}//end for
if(nItem >= nItemCount)
nItem = nItemCount-1;
return FALSE;
}
else
{
for(;;)
{
nSub -= iOp;
if((nItem < m_nCurrentItem && nSub >= nSubcCount) ||
(nItem == 0 && nSub < 0))
{
nItem= m_nCurrentItem;
nSub = m_nCurrentSubItem;
return FALSE;
}
if(nSub < 0)
{
//nSub = nSubcCount -1;
iOp = -1;
nSub = 0;
nItem --;
}
pWnd = m_CtrlMap.GetSubWnd(m_pParentList, nSub);
if (pWnd )
{
pWnd->PostMessage(WM_USER_SHOW_EDIT, nItem, nSub);
return TRUE;
}
}//end for
if(nItem < 0)
nItem = nItemCount-1;
return TRUE;
}
return FALSE;
}
示例15: PreTranslateMessage
BOOL CSHListCtrl::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
// Handle the keystrokes for the left and right keys
// to move the cell selection left and right.
// Handle F2 to commence edit mode from the keyboard.
// Only handle these if the grid control has the focus.
// (Messages also come through here for the edit control
// and we don't want them.
if( this == GetFocus() )
{
if (m_bClickEdit)
m_bKeyEvent = TRUE;
switch( pMsg->wParam )
{
case VK_LEFT:
{
// Decrement the order number.
m_CurSubItem--;
if( m_CurSubItem < -1 )
{
// This indicates that the whole row is selected and F2 means nothing.
m_CurSubItem = -1;
}
else
{
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
// Make the column visible.
// We have to take into account that the header
// may be reordered.
MakeColumnVisible( Header_OrderToIndex( pHeader->m_hWnd, m_CurSubItem ) );
// Invalidate the item.
int iItem = GetNextItem( -1, LVNI_FOCUSED );
if( iItem != -1 )
{
CRect rcBounds;
GetItemRect(iItem, rcBounds, LVIR_BOUNDS);
InvalidateRect( &rcBounds );
}
}
}
return TRUE;
case VK_RIGHT:
{
// Increment the order number.
m_CurSubItem++;
CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// Don't go beyond the last column.
if( m_CurSubItem > nColumnCount -1 )
{
m_CurSubItem = nColumnCount - 1;
}
else
{
// We have to take into account that the header
// may be reordered.
MakeColumnVisible( Header_OrderToIndex( pHeader->m_hWnd, m_CurSubItem ) );
int iItem = GetNextItem( -1, LVNI_FOCUSED );
// Invalidate the item.
if( iItem != -1 )
{
CRect rcBounds;
GetItemRect(iItem, rcBounds, LVIR_BOUNDS);
InvalidateRect( &rcBounds );
}
}
}
return TRUE;
case VK_F2: // Enter nondestructive edit mode.
{
int iItem = GetNextItem( -1, LVNI_FOCUSED );
if( m_CurSubItem != -1 && iItem != -1 )
{
// Send Notification to parent of ListView ctrl
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
CString str;
// We have to take into account that the header
// may be reordered.
str = GetItemText( iItem, Header_OrderToIndex( pHeader->m_hWnd, m_CurSubItem ) );
LV_DISPINFO dispinfo;
dispinfo.hdr.hwndFrom = m_hWnd;
dispinfo.hdr.idFrom = GetDlgCtrlID();
dispinfo.hdr.code = LVN_BEGINLABELEDIT;
dispinfo.item.mask = LVIF_TEXT;
dispinfo.item.iItem = iItem;
// We have to take into account that the header
// may be reordered.
dispinfo.item.iSubItem = Header_OrderToIndex( pHeader->m_hWnd, m_CurSubItem );
dispinfo.item.pszText = (LPTSTR)((LPCTSTR)str);
dispinfo.item.cchTextMax = str.GetLength();
// Send message to the parent that we are ready to edit.
GetParent()->SendMessage( WM_NOTIFY, GetDlgCtrlID(),
(LPARAM)&dispinfo );
}
}
break;
case VK_RETURN:
//.........这里部分代码省略.........