//////////////////////////////////////////////////////////////// //进入编辑状态 //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; }
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; } case 5:{ Sbuffer = client->GetClientSoftVer(); if (Sbuffer.IsEmpty()) Sbuffer = GetResString(IDS_UNKNOWN); break; } case 6:{ if(client->socket){ if(client->socket->IsConnected()){ Sbuffer = GetResString(IDS_YES); break; } } Sbuffer = GetResString(IDS_NO); break; } case 7: Sbuffer = md4str(client->GetUserHash()); break; } if( iColumn != 0) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); }
// ************************************************************************** // 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); }
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; } }
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] } }
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; break; } case 1: if (file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: Sbuffer = CastItoXBytes(client->GetDatarate(), false, true); break; case 3: // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part.. if (thePrefs.m_bExtControls) Sbuffer.Format( _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false)); else Sbuffer = CastItoXBytes(client->GetSessionUp(), false, false); break; case 4: if (client->HasLowID()) Sbuffer.Format(_T("%s (%s)"), CastSecondsToHM(client->GetWaitTime()/1000), GetResString(IDS_IDLOW)); else Sbuffer = CastSecondsToHM(client->GetWaitTime()/1000); break; case 5: Sbuffer = CastSecondsToHM(client->GetUpStartTimeDelay()/1000); break; case 6: Sbuffer = client->GetUploadStateDisplayString(); break; case 7: cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; break; } if (iColumn != 7 && iColumn != 0) dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
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; GCTData.toROUTESrecordID = TRIPS.ROUTESrecordID; GCTData.toSERVICESrecordID = TRIPS.SERVICESrecordID; GCTData.fromNODESrecordID = TRIPS.standard.POGNODESrecordID; GCTData.toNODESrecordID = GTResults.firstNODESrecordID; GCTData.timeOfDay = GTResults.firstNodeTime; deadheadTime = GetConnectionTime(GCT_FLAG_DEADHEADTIME, &GCTData, &distance); distance = (float)fabs((double)distance); if(deadheadTime != NO_TIME) { POTime = GTResults.firstNodeTime - deadheadTime; NODESKey0.recordID = TRIPS.standard.POGNODESrecordID; btrieve(B_GETEQUAL, TMS_NODES, &NODES, &NODESKey0, 0); strncpy(nodeName, NODES.abbrName, NODES_ABBRNAME_LENGTH); trim(nodeName, NODES_ABBRNAME_LENGTH); LVC.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; LVC.fmt = LVCFMT_LEFT; LVC.cx = 50; LVC.pszText = nodeName; pListCtrlTRIPDATA->InsertColumn(pos, &LVC); pos++; } } // // Set the header to the pattern of the trip // PATTERNSKey2.ROUTESrecordID = TRIPS.ROUTESrecordID; PATTERNSKey2.SERVICESrecordID = TRIPS.SERVICESrecordID; PATTERNSKey2.PATTERNNAMESrecordID = TRIPS.PATTERNNAMESrecordID; PATTERNSKey2.directionIndex = TRIPS.directionIndex; PATTERNSKey2.nodeSequence = NO_RECORD; rcode2 = btrieve(B_GETGREATER, TMS_PATTERNS, &PATTERNS, &PATTERNSKey2, 2); while(rcode2 == 0 && PATTERNS.ROUTESrecordID == TRIPS.ROUTESrecordID && PATTERNS.SERVICESrecordID == TRIPS.SERVICESrecordID && PATTERNS.PATTERNNAMESrecordID == TRIPS.PATTERNNAMESrecordID && PATTERNS.directionIndex == TRIPS.directionIndex) { if(!(PATTERNS.flags & PATTERNS_FLAG_BUSSTOP)) { NODESKey0.recordID = PATTERNS.NODESrecordID; btrieve(B_GETEQUAL, TMS_NODES, &NODES, &NODESKey0, 0); strncpy(nodeName, NODES.abbrName, NODES_ABBRNAME_LENGTH); trim(nodeName, NODES_ABBRNAME_LENGTH); LVC.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; LVC.fmt = LVCFMT_LEFT; LVC.cx = 50; LVC.pszText = nodeName; pListCtrlTRIPDATA->InsertColumn(pos, &LVC); pos++; } rcode2 = btrieve(B_GETNEXT, TMS_PATTERNS, &PATTERNS, &PATTERNSKey2, 2); } // // Is this a pull-in? // long PITime = NO_TIME; if(TRIPS.standard.PIGNODESrecordID != NO_RECORD) { GCTData.fromPATTERNNAMESrecordID = TRIPS.PATTERNNAMESrecordID; GCTData.toPATTERNNAMESrecordID = TRIPS.PATTERNNAMESrecordID; GCTData.fromROUTESrecordID = TRIPS.ROUTESrecordID; GCTData.fromSERVICESrecordID = TRIPS.SERVICESrecordID; GCTData.toROUTESrecordID = TRIPS.ROUTESrecordID; GCTData.toSERVICESrecordID = TRIPS.SERVICESrecordID; GCTData.fromNODESrecordID = GTResults.lastNODESrecordID; GCTData.toNODESrecordID = TRIPS.standard.PIGNODESrecordID; GCTData.timeOfDay = GTResults.lastNodeTime; deadheadTime = GetConnectionTime(GCT_FLAG_DEADHEADTIME, &GCTData, &distance); distance = (float)fabs((double)distance); if(deadheadTime != NO_TIME) { PITime = GTResults.lastNodeTime + deadheadTime; NODESKey0.recordID = TRIPS.standard.PIGNODESrecordID; btrieve(B_GETEQUAL, TMS_NODES, &NODES, &NODESKey0, 0); strncpy(nodeName, NODES.abbrName, NODES_ABBRNAME_LENGTH); trim(nodeName, NODES_ABBRNAME_LENGTH); LVC.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; LVC.fmt = LVCFMT_LEFT; LVC.cx = 50; LVC.pszText = nodeName; pListCtrlTRIPDATA->InsertColumn(pos, &LVC); } } // // Display the times // LVITEM LVI; LVI.iItem = 0; LVI.mask = LVIF_TEXT; pos = 0; // // POT? // if(POTime != NO_TIME) { LVI.iSubItem = pos; strcpy(tempString, Tchar(POTime)); LVI.pszText = tempString; pListCtrlTRIPDATA->InsertItem(&LVI); pos++; } // // Do the trip times // strcpy(tempString, Tchar(GTResults.tripTimes[0])); LVI.pszText = tempString; LVI.iSubItem = pos; if(pos == 0) pListCtrlTRIPDATA->InsertItem(&LVI); else { pListCtrlTRIPDATA->SetItem(&LVI); } pos++; for(nI = 1; nI < numNodes; nI++) { LVI.iSubItem = pos; strcpy(tempString, Tchar(GTResults.tripTimes[nI])); LVI.pszText = tempString; pListCtrlTRIPDATA->SetItem(&LVI); pos++; } // // PIT? // if(PITime != NO_TIME) { LVI.iSubItem = pos; strcpy(tempString, Tchar(PITime)); LVI.pszText = tempString; pListCtrlTRIPDATA->SetItem(&LVI); } *pResult = 0; }
/* 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 }
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; }
/* GetColumnCount() Ricava il numero di colonne del controllo. */ int CListViewEx::GetColumnCount() { CHeaderCtrl* pHeader = (CHeaderCtrl*)GetListCtrl().GetDlgItem(0); return(pHeader ? pHeader->GetItemCount() : 0); }
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); }
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; }
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; case PR_HIGH: dwResStrId = IDS_PRIOHIGH; break; case PR_LOW: dwResStrId = IDS_PRIOLOW; break; case PR_VERYLOW: dwResStrId = IDS_PRIOVERYLOW; break; default: dwResStrId = IDS_PRIONORMAL; break; } GetResString(&strBuffer, dwResStrId); } else strBuffer = _T("?"); break; } case QLCOL_PARTS: if (pClient->GetUpPartCount()) strBuffer.Format(_T("%u/%u"), pClient->GetAvailUpPartCount(), pClient->GetUpPartCount()); else strBuffer = _T(""); break; case QLCOL_PROGRESS: { if (pClient->GetUpPartCount() && g_App.m_pPrefs->IsUploadPartsEnabled()) { if (!bMeasuring) { RECT r2; r2.bottom = r.bottom - 1; r2.top = r.top + 1; r2.right = r.right + LIST_CELL_PADDING / 2; r2.left = r.left - LIST_CELL_PADDING / 2; pClient->DrawUpStatusBar(dc, &r2, g_App.m_pPrefs->UseFlatBar()); } iWidth = 300; } break; } case QLCOL_QLRATING: strBuffer.Format(_T("%u"), pClient->GetScore(true)); break; case QLCOL_SCORE: // Note: actually the client, which is downloading from us should be not in WaitingQueue if (pClient->IsDownloading()) strBuffer = _T("-"); else strBuffer.Format((pClient->IsAddNextConnect()) ? _T("%u*") : _T("%u"), pClient->GetScore()); break; case QLCOL_SFRATIO: if (pKnownFile != NULL) strBuffer.Format(_T("%.2f"), pKnownFile->GetSizeRatio()); else strBuffer = _T("-"); break; case QLCOL_RFRATIO: if (pKnownFile != NULL) strBuffer.Format(_T("%.2f"), pKnownFile->GetPopularityRatio()); else strBuffer = _T("-"); break; case QLCOL_TIMESASKED: strBuffer.Format(_T("%u"), pClient->GetAskedCount()); break; case QLCOL_LASTSEEN: strBuffer = CastSecondsToHM((GetTickCount() - pClient->GetLastUpRequest())/1000); break; case QLCOL_ENTEREDQUEUE: strBuffer = CastSecondsToHM((GetTickCount() - pClient->GetWaitStartTime())/1000); break; case QLCOL_BANNED: strBuffer = YesNoStr(pClient->IsBanned()); break; case QLCOL_COUNTRY: strBuffer = pClient->GetCountryName(); break; } if (iColumn != QLCOL_PROGRESS) { dc->DrawText(strBuffer, &r, iCalcFlag); if (bMeasuring && !strBuffer.IsEmpty()) iWidth += r.right - r.left + 1; } r.left = r.right + LIST_CELL_PADDING; if (bMeasuring) { // Pin the column widths at some reasonable value if (iWidth < 40) iWidth = 40; if (iWidth > m_iColumnMaxWidths[m_iMeasuringColumn]) m_iColumnMaxWidths[m_iMeasuringColumn] = iWidth; } } // Draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT rOutline = lpDrawItemStruct->rcItem; CBrush FrmBrush((bCtrlFocused) ? m_crFocusLine : m_crNoFocusLine); rOutline.left++; rOutline.right--; dc->FrameRect(&rOutline, &FrmBrush); } if (pOldFont) dc.SelectObject(pOldFont); if (crOldTextColor) dc.SetTextColor(crOldTextColor); #undef LIST_CELL_PADDING }
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; }
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: { // 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 ); } } // 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); } } return TRUE; default: break; } } } m_tooltip.RelayEvent(pMsg); return CListCtrl::PreTranslateMessage(pMsg); }
/* GetColumnCount() Ricava il numero di colonne del controllo. */ int CListCtrlEx::GetColumnCount(void) { CHeaderCtrl* pHeader = (CHeaderCtrl*)CListCtrl::GetDlgItem(0); return(pHeader ? pHeader->GetItemCount() : 0); }
CSHInPlaceEdit* CSHListCtrl::ShowInPlaceEditEx(int nItem, int nSubitem, DWORD dwStyle) { CSHInPlaceEdit* pEdit = new CSHInPlaceEdit(nItem, nSubitem); CRect rect(0,0,1,1); dwStyle |= ES_LEFT | WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; pEdit->Create(dwStyle, rect, this, IDC_INPLACE_EDIT); CSHInPlaceButton* pButton = new CSHInPlaceButton(nItem, nSubitem); dwStyle = WS_CHILD | WS_VISIBLE; pButton->Create("...", dwStyle, rect, this, IDC_INPLACE_BUTTON); pEdit->SetButtonCtrl(pButton); pButton->SetEditCtrl(pEdit); // if (!EnsureVisible(nItem, TRUE)) return NULL; // Make sure that nCol is valid CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); ASSERT(nSubitem >= 0 && nSubitem < nColumnCount); if (nSubitem >= nColumnCount || // We have to take into account that the header may be reordered GetColumnWidth(Header_OrderToIndex( pHeader->m_hWnd, nSubitem)) < 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] != nSubitem; i++) offset += GetColumnWidth(orderarray[i]); int colwidth = GetColumnWidth(nSubitem); delete[] orderarray; GetItemRect(nItem, &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; rect.bottom--; CRect rcButton; rcButton = rect; rcButton.left = rcButton.right - rcButton.Height(); rect.right = rect.right - rect.Height(); pEdit->MoveWindow(&rect); pButton->MoveWindow(&rcButton); // PositionControl(pEdit, nItem, nSubitem); pEdit->CalculateSize(); pEdit->GetWindowRect( &rect ); rect.left = rect.right; rect.right += rect.Height(); ScreenToClient( &rect ); pButton->MoveWindow(&rect); CString sText = GetItemText(nItem, nSubitem); pEdit->SetWindowText(sText); pEdit->SetSel(0, -1); return pEdit; }
void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult) { NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR); *pResult = CDRF_DODEFAULT; if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) { m_itemGroups.SetSize(m_list.GetItemCount()); m_totalGroups = 0; for (int i = 0, j = m_list.GetItemCount(); i < j; i++) { if (m_list.GetItemData(i)&TSEP) { m_totalGroups++; } m_itemGroups[i] = m_totalGroups; } *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW; } else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) { pLVCD->nmcd.uItemState &= ~CDIS_FOCUS; *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYSUBITEMDRAW; } else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) { COLORREF clrText; COLORREF clrTextBk; if ((pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_TEXT || pLVCD->iSubItem == COL_STYLE || pLVCD->iSubItem == COL_LAYER || pLVCD->iSubItem == COL_ACTOR || pLVCD->iSubItem == COL_EFFECT) && m_mode == TEXTSUB) { clrText = 0; } else if ((pLVCD->iSubItem == COL_START) && m_mode == VOBSUB) { clrText = 0; } else { clrText = 0x606060; } clrTextBk = 0xffffff; // if (m_totalGroups > 0) clrTextBk -= ((m_itemGroups[pLVCD->nmcd.dwItemSpec] & 1) ? 0x100010 : 0x200020); if (m_sts[pLVCD->nmcd.dwItemSpec].start <= m_rt / 10000 && m_rt / 10000 < m_sts[pLVCD->nmcd.dwItemSpec].end) { clrText |= 0xFF; } int nCheck = (int)m_list.GetItemData((int)pLVCD->nmcd.dwItemSpec); if ((nCheck & 1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART)) { clrTextBk = 0xffddbb; } else if ((nCheck & 4) && (/*pLVCD->iSubItem == COL_START ||*/ pLVCD->iSubItem == COL_PREVSTART)) { clrTextBk = 0xffeedd; } if ((nCheck & 2) && (pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_PREVEND)) { clrTextBk = 0xffddbb; } else if ((nCheck & 8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND)) { clrTextBk = 0xffeedd; } pLVCD->clrText = clrText; pLVCD->clrTextBk = clrTextBk; *pResult = CDRF_NOTIFYPOSTPAINT; } else if ((CDDS_ITEMPOSTPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) { // *pResult = CDRF_DODEFAULT; } else if (CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage) { int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec); LVITEM rItem; ZeroMemory(&rItem, sizeof(LVITEM)); rItem.mask = LVIF_IMAGE | LVIF_STATE; rItem.iItem = nItem; rItem.stateMask = LVIS_SELECTED; m_list.GetItem(&rItem); { CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc); CRect rcItem; m_list.GetItemRect(nItem, &rcItem, LVIR_BOUNDS); { bool fSeparator = nItem < m_list.GetItemCount() - 1 && (m_list.GetItemData(nItem + 1)&TSEP); CPen p(PS_INSIDEFRAME, 1, fSeparator ? 0x404040 : 0xe0e0e0); CPen* old = pDC->SelectObject(&p); pDC->MoveTo(CPoint(rcItem.left, rcItem.bottom - 1)); pDC->LineTo(CPoint(rcItem.right, rcItem.bottom - 1)); pDC->SelectObject(old); } { CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0); CPen* old = pDC->SelectObject(&p); CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); // Get the column offset int offset = rcItem.left; for (int i = 0; i < nColumnCount; i++) { offset += m_list.GetColumnWidth(i); pDC->MoveTo(CPoint(offset, rcItem.top)); pDC->LineTo(CPoint(offset, rcItem.bottom)); } pDC->SelectObject(old); } *pResult = CDRF_SKIPDEFAULT; } } else if (CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage) { } }
void CDlgBDSelectRezTL::OnBnClickedButtonExportExcel() { CDatabase database; CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)"; // exactly the same name as in the ODBC-Manager CString sExcelFile = "Тележки1067.xls"; // Filename and path for the file to be created if( iNewProc ) sExcelFile = "Тележки1067arx.xls"; CString sSql; CString strColListInsert = ""; CString strColListCreate = ""; int iColCount = 0; LVITEM Item; HDITEM hItem; enum { sizeOfBuffer = 256 }; TCHAR lpBuffer[sizeOfBuffer]; bool fFound = false; hItem.mask = HDI_TEXT; hItem.pszText = lpBuffer; hItem.cchTextMax = sizeOfBuffer; CHeaderCtrl *hcHeader = m_List.GetHeaderCtrl(); iColCount = hcHeader->GetItemCount(); CString strTitle = ""; for( int i = 0; i < iColCount; i++ ) { if( i ) { strColListInsert += ", "; strColListCreate += ", "; } if( hcHeader->GetItem(i, &hItem) ) { strTitle = hItem.pszText; strTitle.Remove('.'); strColListInsert = strColListInsert + "[" + strTitle + "]"; strColListCreate = strColListCreate + "[" + strTitle + "] TEXT"; } } // Build the creation string for access without DSN DeleteFile(".\\" + sExcelFile); if( !CopyFile(".\\html\\" + sExcelFile, ".\\" + sExcelFile, 1) ) { // Создам шаблон sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\".\\html\\%s\";DBQ=.\\html\\%s", sDriver, sExcelFile, sExcelFile); database.OpenEx(sSql,CDatabase::noOdbcDialog); sSql = "CREATE TABLE [Тележки 1067] (" + strColListCreate + ")"; database.ExecuteSQL(sSql); database.Close(); CopyFile(".\\html\\" + sExcelFile, ".\\" + sExcelFile, 1); } sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\".\\%s\";DBQ=%s", sDriver, sExcelFile, sExcelFile); // Create the database (i.e. Excel sheet) if( database.OpenEx(sSql,CDatabase::noOdbcDialog) ) { /* TRY { sSql = "CREATE TABLE [Тележки 1067] (" + strColListCreate + ")"; database.ExecuteSQL(sSql); } CATCH_ALL(e) { } END_CATCH_ALL */ for( int i = 0; i < m_List.GetItemCount(); i++ ) { CString strLine = ""; for( int j = 0; j < iColCount; j++ ) { if( j ) strLine += ", "; strLine += "'" + m_List.GetItemText(i, j) + "'"; } //sSql = "INSERT INTO [Тележки 1067] (" + strColListInsert + ") VALUES ( " + strLine + " )"; sSql = "INSERT INTO [Тележки 1067] VALUES ( " + strLine + " )"; database.ExecuteSQL(sSql); } } database.Close(); CString str = "excel.exe .\\" + sExcelFile; ShellExecute(NULL, "open", "excel.exe", sExcelFile, NULL, SW_SHOWNORMAL); }
void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR; if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) { enum { TOGSEP = 1, DUPITEM, DELITEM, RESETS, SETOS, SETCS, RESETE, SETOE, SETCE, STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT, UNICODEYES, UNICODENO, LAYERDEC, LAYERINC, ACTORFIRST, ACTORLAST = ACTORFIRST + 1000, EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000 }; CStringArray styles; CStringArray actors; CStringArray effects; CMenu m; m.CreatePopupMenu(); if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR)); m.AppendMenu(MF_SEPARATOR); if (m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE)); } m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE)); } switch (lpnmlv->iSubItem) { case COL_START: if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5")); } break; case COL_END: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6")); } break; case COL_STYLE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); int id = STYLEFIRST; POSITION pos = m_sts.m_styles.GetStartPosition(); while (pos && id <= STYLELAST) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); styles.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT)); } } break; case COL_UNICODE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES)); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO)); } break; case COL_LAYER: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE)); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE)); } break; case COL_ACTOR: if (m_mode == TEXTSUB) { CMapStringToPtr actormap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { actormap[m_sts[i].actor] = NULL; } actormap.RemoveKey(_T("")); if (!actormap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = ACTORFIRST; POSITION pos = actormap.GetStartPosition(); while (pos && id <= ACTORLAST) { CString key; void* val; actormap.GetNextAssoc(pos, key, val); actors.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; case COL_EFFECT: if (m_mode == TEXTSUB) { CMapStringToPtr effectmap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { effectmap[m_sts[i].effect] = NULL; } effectmap.RemoveKey(_T("")); if (!effectmap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = EFFECTFIRST; POSITION pos = effectmap.GetStartPosition(); while (pos && id <= EFFECTLAST) { CString key; void* val; effectmap.GetNextAssoc(pos, key, val); effects.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; } CPoint p = lpnmlv->ptAction; ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1); UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this); bool fNeedsUpdate = false; POSITION pos = m_list.GetFirstSelectedItemPosition(); while (pos) { int iItem = m_list.GetNextSelectedItem(pos); SubTime& st = m_subtimes[iItem]; switch (id) { case TOGSEP: m_list.SetItemData(iItem, m_list.GetItemData(iItem) ^ TSEP); m_list.Invalidate(); fNeedsUpdate = true; break; case DUPITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; STSEntry stse = m_sts[iItem]; m_sts.InsertAt(iItem + 1, stse); SubTime st = m_subtimes[iItem]; m_subtimes.InsertAt(iItem + 1, st); CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); CStringArray sa; sa.SetSize(nColumnCount); for (int col = 0; col < nColumnCount; col++) { sa[col] = m_list.GetItemText(iItem, col); } DWORD_PTR data = m_list.GetItemData(iItem); m_list.InsertItem(iItem + 1, sa[0]); m_list.SetItemData(iItem + 1, data); for (int col = 1; col < nColumnCount; col++) { m_list.SetItemText(iItem + 1, col, sa[col]); } } } fNeedsUpdate = true; break; case DELITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; m_sts.RemoveAt(iItem); m_subtimes.RemoveAt(iItem); m_list.DeleteItem(iItem); } iItem = items[items.GetCount() - 1]; if (iItem >= m_list.GetItemCount()) { iItem = m_list.GetItemCount() - 1; } m_list.SetSelectionMark(iItem); } fNeedsUpdate = true; break; case RESETS: /*if (*/ ModStart(iItem, st.orgstart, true);/*)*/ fNeedsUpdate = true; break; case SETOS: /*if (*/ ModStart(iItem, st.orgstart);/*)*/ fNeedsUpdate = true; break; case SETCS: /*if (*/ ModStart(iItem, (int)(m_rt / 10000)); /*)*/ fNeedsUpdate = true; break; case RESETE: /*if (*/ ModEnd(iItem, st.orgend, true);/*)*/ fNeedsUpdate = true; break; case SETOE: /*if (*/ ModEnd(iItem, st.orgend);/*)*/ fNeedsUpdate = true; break; case SETCE: /*if (*/ ModEnd(iItem, (int)(m_rt / 10000)); /*)*/ fNeedsUpdate = true; break; default: if (STYLEFIRST <= id && id <= STYLELAST) { CString s = styles[id - STYLEFIRST]; if (m_sts[iItem].style != s) { fNeedsUpdate = true; } m_sts[iItem].style = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (id == STYLEEDIT) { CAutoPtrArray<CPPageSubStyle> pages; CAtlArray<STSStyle*> styles; STSStyle* stss = m_sts.GetStyle(iItem); int iSelPage = 0; POSITION pos = m_sts.m_styles.GetStartPosition(); for (int i = 0; pos; i++) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle()); page->InitSubStyle(key, val); pages.Add(page); styles.Add(val); if (stss == val) { iSelPage = i; } } CPropertySheet dlg(_T("Styles..."), this, iSelPage); for (size_t i = 0, l = pages.GetCount(); i < l; i++) { dlg.AddPage(pages[i]); } if (dlg.DoModal() == IDOK) { for (size_t j = 0, l = pages.GetCount(); j < l; j++) { stss = styles[j]; pages[j]->GetSubStyle(stss); for (int i = 0; i < (int)m_sts.GetCount(); i++) { if (m_sts.GetStyle(i) == stss) { CString str; m_list.SetItemText(i, COL_TEXT, m_sts.GetStrW(i, true)); m_list.SetItemText(i, COL_FONT, stss->fontName); str.Format(_T("%d"), stss->charSet); m_list.SetItemText(i, COL_CHARSET, str); str.Format(_T("%d"), m_sts[i].layer); } } } fNeedsUpdate = true; } } else if (id == UNICODEYES || id == UNICODENO) { m_sts.ConvertUnicode(iItem, id == UNICODEYES); m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStrW(iItem, true)); m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no")); fNeedsUpdate = true; } else if (id == LAYERDEC || id == LAYERINC) { int d = (id == LAYERDEC) ? -1 : 1; fNeedsUpdate = true; m_sts[iItem].layer += d; CString s; s.Format(_T("%d"), m_sts[iItem].layer); m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (ACTORFIRST <= id && id <= ACTORLAST) { CString s = actors[id - ACTORFIRST]; if (m_sts[iItem].actor != s) { fNeedsUpdate = true; } m_sts[iItem].actor = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (EFFECTFIRST <= id && id <= EFFECTLAST) { CString s = effects[id - EFFECTFIRST]; if (m_sts[iItem].effect != s) { fNeedsUpdate = true; } m_sts[iItem].effect = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } break; } } if (fNeedsUpdate) { UpdatePreview(); } } *pResult = 0; }
void CIrcChannelListCtrl::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 ChannelName* pChannel = (ChannelName*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor(m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE) { DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CString strBuff; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { int cx = GetColumnWidth(iColumn); cur_rec.right += cx; switch (iColumn) { case 0: strBuff = pChannel->m_sName; break; case 1: strBuff.Format(_T("%u"), pChannel->m_uUsers); break; case 2: strBuff = pChannel->m_sDesc; break; } dc->DrawText(strBuff, strBuff.GetLength(), &cur_rec, DT_LEFT); cur_rec.left += cx; } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc->FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc->FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc->FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
void CServerListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) // 与 IP to Country 有关,不能注释掉 { if( !theApp.emuledlg->IsRunning() ) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this ) || (GetStyle() & LVS_SHOWSELALWAYS)); if( (lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED )){ if(bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CServer* server = (CServer*)lpDrawItemStruct->itemData; CRect rcItem(lpDrawItemStruct->rcItem); CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); RECT cur_rec = rcItem; COLORREF crOldTextColor = dc.SetTextColor(m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CString Sbuffer; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; for(int iCurrent = 0; iCurrent < iCount; iCurrent++){ int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if( !IsColumnHidden(iColumn) ){ cur_rec.right += GetColumnWidth(iColumn); RECT cur_backup = cur_rec; Sbuffer = GetItemText(lpDrawItemStruct->itemID, iColumn); switch(iColumn) { case 0: { POINT point = {cur_rec.left, cur_rec.top};//check CServer* cur_srv; if (theApp.serverconnect->IsConnected() && (cur_srv = theApp.serverconnect->GetCurrentServer()) != NULL && cur_srv->GetPort() == server->GetPort() && _tcsicmp(cur_srv->GetAddress(), server->GetAddress()) == 0) { imagelist.Draw(dc,0, point, ILD_NORMAL | INDEXTOOVERLAYMASK(1)); } else { imagelist.Draw(dc,0, point, ILD_NORMAL); } cur_rec.left += 20; } //EastShare Start - added by AndCycle, IP to Country Sbuffer = server->GetCountryName() + Sbuffer; if(theApp.ip2country->ShowCountryFlag()){ POINT point = {cur_rec.left, cur_rec.top};//check theApp.ip2country->GetFlagImageList()->DrawIndirect(dc, server->GetCountryFlagIndex(), point, CSize(18,16), CPoint(0,0), ILD_NORMAL); cur_rec.left +=20; } //EastShare End - added by AndCycle, IP to Country break; } //get the text justification LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; GetColumn(iColumn, &lvc); UINT nJustify = DT_LEFT; switch(lvc.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } #define MLC_DT_TEXT (DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS) dc->DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,MLC_DT_TEXT | nJustify); cur_rec = cur_backup; cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if ((lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED)) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc->FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if(bCtrlFocused) dc->FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc->FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; // ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle /* CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); */ CMemoryDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); // <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle BOOL bCtrlFocused; //Xman narrow font at transferwindow /* InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused); */ // ==> Design Settings [eWombat/Stulle] - Stulle /* InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true); //Xman end */ InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true, style_b_queuelist); // <== Design Settings [eWombat/Stulle] - Stulle CRect cur_rec(lpDrawItemStruct->rcItem); CRect rcClient; GetClientRect(&rcClient); const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData; // ==> Design Settings [eWombat/Stulle] - Stulle /* COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease //Xman show LowIDs */ // <== Design Settings [eWombat/Stulle] - Stulle CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - sm_iLabelOffset; cur_rec.left += sm_iIconOffset; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { UINT uDrawTextAlignment; int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment); cur_rec.right += iColumnWidth; if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec)) { TCHAR szItem[1024]; GetItemDisplayText(client, iColumn, szItem, _countof(szItem)); switch (iColumn) { case 0:{ int iImage; //Xman Show correct Icons /* if (client->IsFriend()) iImage = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 8; else iImage = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 6; else iImage = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 10; else iImage = 9; } else if (client->GetClientSoft() == SO_AMULE) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 12; else iImage = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 14; else iImage = 13; } else if (client->ExtProtocolAvailable()) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 3; else iImage = 1; } else { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 2; else iImage = 0; } */ if (client->IsFriend()) iImage = 6; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ iImage = 10; } else if (client->GetClientSoft() == SO_EDONKEY){ iImage = 2; } else if (client->GetClientSoft() == SO_MLDONKEY){ iImage = 8; } else if (client->GetClientSoft() == SO_SHAREAZA){ iImage = 12; } else if (client->GetClientSoft() == SO_AMULE){ iImage = 14; } else if (client->GetClientSoft() == SO_LPHANT){ iImage = 16; } else if (client->ExtProtocolAvailable()){ // ==> Mod Icons - Stulle /* iImage = 4; */ if(client->GetModClient() == MOD_NONE) iImage = 4; else iImage = (uint8)(client->GetModClient() + 19); // <== Mod Icons - Stulle } else{ iImage = 0; } //Xman Anti-Leecher if(client->IsLeecher()>0) iImage=18; else //Xman end if (((client->credits)?client->credits->GetScoreRatio(client):0) > 1) // ==> Mod Icons - Stulle // ==> CreditSystems [EastShare/ MorphXT] - Stulle /* iImage++; */ if (client->GetModClient() == MOD_NONE){ if(client->credits && client->credits->GetHasScore(client)) iImage++; } // <== CreditSystems [EastShare/ MorphXT] - Stulle // <== Mod Icons - Stulle //Xman end UINT nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; //Xman changed: display the obfuscation icon for all clients which enabled it /* if (client->IsObfuscatedConnectionEstablished()) */ if(client->IsObfuscatedConnectionEstablished() || (!(client->socket != NULL && client->socket->IsConnected()) && (client->SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested())))) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = { cur_rec.left, cur_rec.top + iIconPosY }; m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); // ==> Mod Icons - Stulle if(client->Credits() && client->credits->GetHasScore(client) && client->GetModClient() != MOD_NONE) { if (nOverlayImage & 1) m_overlayimages.Draw(dc,1, point, ILD_TRANSPARENT); else m_overlayimages.Draw(dc,0, point, ILD_TRANSPARENT); } // <== Mod Icons - Stulle //Xman friend visualization if (client->IsFriend() && client->GetFriendSlot()) m_ImageList.Draw(dc,19, point, ILD_NORMAL); //Xman end //EastShare Start - added by AndCycle, IP to Country if(theApp.ip2country->ShowCountryFlag() ) { cur_rec.left+=20; POINT point2= {cur_rec.left,cur_rec.top+1}; //theApp.ip2country->GetFlagImageList()->Draw(dc, client->GetCountryFlagIndex(), point2, ILD_NORMAL); theApp.ip2country->GetFlagImageList()->DrawIndirect(&theApp.ip2country->GetFlagImageDrawParams(dc,client->GetCountryFlagIndex(),point2)); cur_rec.left += sm_iLabelOffset; } //EastShare End - added by AndCycle, IP to Country cur_rec.left += 16 + sm_iLabelOffset; dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); cur_rec.left -= 16; cur_rec.right -= sm_iSubItemInset; //EastShare Start - added by AndCycle, IP to Country if(theApp.ip2country->ShowCountryFlag() ) { cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 9: if (client->GetUpPartCount()) { cur_rec.bottom--; cur_rec.top++; COLORREF crOldBackColor = dc->GetBkColor(); //Xman Code Improvement: FillSolidRect client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); dc.SetBkColor(crOldBackColor); //Xman Code Improvement: FillSolidRect //Xman client percentage (font idea by morph) CString buffer; // ==> Show Client Percentage optional [Stulle] - Stulle /* if (thePrefs.GetUseDwlPercentage()) */ if (thePrefs.GetShowClientPercentage()) // <== Show Client Percentage optional [Stulle] - Stulle { if(client->GetHisCompletedPartsPercent_UP() >=0) { COLORREF oldclr = dc.SetTextColor(RGB(0,0,0)); int iOMode = dc.SetBkMode(TRANSPARENT); buffer.Format(_T("%i%%"), client->GetHisCompletedPartsPercent_UP()); CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller); #define DrawClientPercentText dc.DrawText(buffer, buffer.GetLength(),&cur_rec, ((MLC_DT_TEXT | DT_RIGHT) & ~DT_LEFT) | DT_CENTER) cur_rec.top-=1;cur_rec.bottom-=1; DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1; DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1; DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1; DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1; DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1; DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1; DrawClientPercentText;cur_rec.top-=1;cur_rec.bottom-=1; DrawClientPercentText;cur_rec.left++;cur_rec.right++; dc.SetTextColor(RGB(255,255,255)); DrawClientPercentText; dc.SelectObject(pOldFont); dc.SetBkMode(iOMode); dc.SetTextColor(oldclr); } } //Xman end cur_rec.bottom++; cur_rec.top--; } break; default: // ==> Design Settings [eWombat/Stulle] - Stulle /* //Xman PowerRelease //Xman show LowIDs if(iColumn == 1) { const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); if(file && file->GetUpPriority()==PR_POWER) dc.SetBkColor(RGB(255,225,225)); } else if(iColumn == 10 && client->HasLowID()) dc.SetBkColor(RGB(255,250,200)); //Xman end */ // <== Design Settings [eWombat/Stulle] - Stulle dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); // ==> Design Settings [eWombat/Stulle] - Stulle /* dc.SetBkColor(crOldBackColor); //Xman PowerRelease //Xman show LowIDs */ // <== Design Settings [eWombat/Stulle] - Stulle break; } } cur_rec.left += iColumnWidth; } } DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED); }
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 CQueueListCtrl::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; 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) { //==> Xman CreditSystem [shadow2004] 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) //==>Modversion [shadow2004] #ifdef MODVERSION image = (client->IsNextEMF())?16:3; #else //Modversion image = 3; #endif //Modversion //<==Modversion [shadow2004] else //==>Modversion [shadow2004] #ifdef MODVERSION image = (client->IsNextEMF())?16:1; #else //Modversion image = 1; #endif //Modversion //<==Modversion [shadow2004] } else { if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) //==> Xman CreditSystem [shadow2004] 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; break; } case 1: if(file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: if(file) { switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } default: Sbuffer.Empty(); } } else Sbuffer = _T("?"); break; case 3: Sbuffer.Format(_T("%i"),client->GetScore(false,false,true)); break; case 4: if (client->HasLowID()) { if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),client->GetScore(false)); else Sbuffer.Format(_T("%i LowID"),client->GetScore(false)); } else Sbuffer.Format(_T("%i"),client->GetScore(false)); break; case 5: Sbuffer.Format(_T("%i"),client->GetAskedCount()); break; case 6: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000); break; case 7: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000); break; case 8: if(client->IsBanned()) Sbuffer = GetResString(IDS_YES); else Sbuffer = GetResString(IDS_NO); break; case 9: if( client->GetUpPartCount()) { cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc,&cur_rec,false); cur_rec.bottom++; cur_rec.top--; } break; //==>Modversion [shadow2004] #ifdef MODVERSION case 10: Sbuffer = client->GetClientSoftVer(); break; #endif //Modversion //<==Modversion [shadow2004] }
void CQueueListCtrl::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; 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; } uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = {cur_rec.left, cur_rec.top + iIconPosY}; imagelist.Draw(dc,image, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); Sbuffer = client->GetUserName(); cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; break; } case 1: if(file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: if(file){ switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } default: Sbuffer.Empty(); } } else Sbuffer = _T("?"); break; case 3: Sbuffer.Format(_T("%i"),client->GetScore(false,false,true)); break; case 4: if (client->HasLowID()){ if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),client->GetScore(false)); else Sbuffer.Format(_T("%i (%s)"),client->GetScore(false), GetResString(IDS_IDLOW)); } else Sbuffer.Format(_T("%i"),client->GetScore(false)); break; case 5: Sbuffer.Format(_T("%i"),client->GetAskedCount()); break; case 6: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000); break; case 7: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000); break; case 8: if(client->IsBanned()) Sbuffer = GetResString(IDS_YES); else Sbuffer = GetResString(IDS_NO); break; case 9: if( client->GetUpPartCount()){ cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc,&cur_rec,false,thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; } break; } if( iColumn != 9 && iColumn != 0) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } // draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if(bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
// ************************************************************************** // EditSubLabel () // // Description: // Edit the subitem value. Creates a CEdit object sized and placed to cover // list control cell. This edit box is needed to receive user input, and // will delete itself when its parent window is destroyed. // // Parameters: // int nItem Index of item // int nCol Column of item // // Returns: // CEdit* - Pointer to a CEdit object to be used to edit cell. // ************************************************************************** CEdit* CKListEditCtrl::EditSubLabel (int nItem, int nCol) { int cnColumns = 0; int nColOffset = 0; // Make sure that the item is visible: if (!EnsureVisible (nItem, TRUE)) return (NULL); // Get the number of columns: CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0); cnColumns = pHeader->GetItemCount (); // Make sure that column is valid: if (nCol >= cnColumns || GetColumnWidth (nCol) < 5) return (NULL); // Get the column offset (from left boundary): nColOffset = 0; for (int i = 0; i < nCol; i++) nColOffset += GetColumnWidth (i); // Get selected item's rectangle: CRect rect; GetItemRect (nItem, &rect, LVIR_BOUNDS); // Scroll if we need to expose the column: CRect rcClient; GetClientRect (&rcClient); if (nColOffset + rect.left < 0 || nColOffset + rect.left > rcClient.right) { CSize size; size.cx = nColOffset + 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; switch (lvcol.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_LEFT: dwStyle = ES_LEFT; break; case LVCFMT_RIGHT: dwStyle = ES_RIGHT; break; default: dwStyle = ES_CENTER; break; } rect.left += (nColOffset + 4); rect.right = rect.left + GetColumnWidth (nCol) - 10; if (rect.right > rcClient.right) rect.right = rcClient.right; // Defile edit control (base class) style: dwStyle |= WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // Create a new CKListEdit box (not to be confused with CKListEditCtrl): CEdit *pEdit = new CKListEdit (nItem, nCol, GetItemText (nItem, nCol)); // Set style, size and position using base class: pEdit->Create (dwStyle, rect, this, IDC_LISTEDIT); // Update currently selected item: m_nSelItem = nItem; // Return pointer to new CKListEdit control: return (pEdit); }
void CDragDropListCtrl::DropItem() { RestorePrevDropItemState(); // Drop after currently selected item. m_nDropIndex++; if (m_nDropIndex < 0 || m_nDropIndex > GetItemCount() - 1) { // Fail safe - invalid drop index, so drop at end of list. m_nDropIndex = GetItemCount(); } int nColumns = 1; CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); if (pHeader) { nColumns = pHeader->GetItemCount(); } // »Øµ÷ if( m_callbackFunc != NULL ) { if( m_callbackFunc(m_nDropIndex, std::tr1::ref(m_anDragIndexes)) == false ) return; } // Move all dragged items to their new positions. for (int nDragItem = 0; nDragItem < m_anDragIndexes.GetSize(); nDragItem++) { int nDragIndex = m_anDragIndexes[nDragItem]; if (nDragIndex > -1 && nDragIndex < GetItemCount()) { // Get information about this drag item. char szText[256]; LV_ITEM lvItem; ZeroMemory(&lvItem, sizeof(LV_ITEM)); lvItem.iItem = nDragIndex; lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM; lvItem.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED | LVIS_STATEIMAGEMASK; lvItem.pszText = szText; lvItem.cchTextMax = sizeof(szText) - 1; GetItem(&lvItem); BOOL bChecked = GetCheck(nDragIndex); // Before moving drag item, make sure it is deselected in its original location, // otherwise GetSelectedCount() will return 1 too many. SetItemState(nDragIndex, static_cast<UINT>(~LVIS_SELECTED), LVIS_SELECTED); // Insert the dragged item at drop index. lvItem.iItem = m_nDropIndex; InsertItem(&lvItem); if (bChecked) { SetCheck(m_nDropIndex); } // Index of dragged item will change if item has been dropped above itself. if (nDragIndex > m_nDropIndex) { nDragIndex++; } // Fill in all the columns for the dragged item. lvItem.mask = LVIF_TEXT; lvItem.iItem = m_nDropIndex; for (int nColumn = 1; nColumn < nColumns; nColumn++) { _tcscpy(lvItem.pszText, (LPCTSTR)(GetItemText(nDragIndex, nColumn))); lvItem.iSubItem = nColumn; SetItem(&lvItem); } // Delete the original item. DeleteItem(nDragIndex); // Need to adjust indexes of remaining drag items. for (int nNewDragItem = nDragItem; nNewDragItem < m_anDragIndexes.GetSize(); nNewDragItem++) { int nNewDragIndex = m_anDragIndexes[nNewDragItem]; if (nDragIndex < nNewDragIndex && nNewDragIndex < m_nDropIndex) { // Item has been removed from above this item, and inserted after it, // so this item moves up the list. m_anDragIndexes[nNewDragItem] = max(nNewDragIndex - 1, 0); } else if (nDragIndex > nNewDragIndex && nNewDragIndex > m_nDropIndex) { // Item has been removed from below this item, and inserted before it, // so this item moves down the list. m_anDragIndexes[nNewDragItem] = nNewDragIndex + 1; } } if (nDragIndex > m_nDropIndex) { // Item has been added before the drop target, so drop target moves down the list. m_nDropIndex++; } } } if (m_dwStyle != NULL) { // Style was modified, so return it back to original style. ModifyStyle(NULL, m_dwStyle); m_dwStyle = NULL; } }
void CDownloadClientsCtrl::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; 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->credits != NULL){ if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ //==> Xman CreditSystem [shadow2004] 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) //<== Xman CreditSystem [shadow2004] image = 2; else image = 0; } } else image = 0; POINT point = {cur_rec.left, cur_rec.top+1}; m_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; break; } case 1: Sbuffer.Format(_T("%s"), client->GetClientSoftVer()); break; case 2: Sbuffer.Format(_T("%s"), client->GetRequestFile()->GetFileName()); break; case 3: Sbuffer=CastItoXBytes( (float)client->GetDownloadDatarate() , false, true); dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec, DLC_DT_TEXT | DT_RIGHT); break; case 4: cur_rec.bottom--; cur_rec.top++; client->DrawStatusBar(dc, &cur_rec, false); cur_rec.bottom++; cur_rec.top--; break; case 5: if(client->Credits() && client->GetSessionDown() < client->credits->GetDownloadedTotal()) Sbuffer.Format(_T("%s (%s)"), CastItoXBytes(client->GetSessionDown()), CastItoXBytes(client->credits->GetDownloadedTotal())); else Sbuffer.Format(_T("%s"), CastItoXBytes(client->GetSessionDown())); break; case 6: if(client->Credits() && client->GetSessionUp() < client->credits->GetUploadedTotal()) Sbuffer.Format(_T("%s (%s)"), CastItoXBytes(client->GetSessionUp()), CastItoXBytes(client->credits->GetUploadedTotal())); else Sbuffer.Format(_T("%s"), CastItoXBytes(client->GetSessionUp())); break; case 7: switch(client->GetSourceFrom()){ case SF_SERVER: Sbuffer = _T("eD2K Server"); break; case SF_KADEMLIA: Sbuffer = GetResString(IDS_KADEMLIA); break; case SF_SOURCE_EXCHANGE: Sbuffer = GetResString(IDS_SE); break; case SF_PASSIVE: Sbuffer = GetResString(IDS_PASSIVE); break; case SF_LINK: Sbuffer = GetResString(IDS_SW_LINK); break; default: Sbuffer = GetResString(IDS_UNKNOWN); break; } break; } if( iColumn != 4 && iColumn != 0 && iColumn != 3 && iColumn != 11) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
void CDownloadClientsCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); BOOL bCtrlFocused; InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused); CRect cur_rec(lpDrawItemStruct->rcItem); CRect rcClient; GetClientRect(&rcClient); const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - sm_iLabelOffset; cur_rec.left += sm_iIconOffset; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { UINT uDrawTextAlignment; int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment); cur_rec.right += iColumnWidth; if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec)) { TCHAR szItem[1024]; GetItemDisplayText(client, iColumn, szItem, _countof(szItem)); switch (iColumn) { case 0:{ int iImage; if (client->credits != NULL) { if (client->IsFriend()) iImage = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 8; else iImage = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 6; else iImage = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 10; else iImage = 9; } else if (client->GetClientSoft() == SO_AMULE) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 12; else iImage = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 14; else iImage = 13; } else if (client->ExtProtocolAvailable()) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 3; else iImage = 1; } else { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 2; else iImage = 0; } } else iImage = 0; UINT nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = { cur_rec.left, cur_rec.top + iIconPosY }; m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); cur_rec.left += 16 + sm_iLabelOffset; dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); cur_rec.left -= 16; cur_rec.right -= sm_iSubItemInset; break; } case 4: cur_rec.bottom--; cur_rec.top++; client->DrawStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; break; default: dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); break; } } cur_rec.left += iColumnWidth; } } DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED); }