BOOL CDrawInfo::DrawSelf( CDC* pDC, CPoint pos, int nItemID, CRect& rcItem ) { int nAyIndex = GetArrayIndexFromPoint(pos); int nCellIndex = PointToIndex(pos); if (nAyIndex != -1) {// 当前鼠标所在的资讯索引单元格 if (m_nActiveCellID == nCellIndex) { // 画激活背景 rcItem.DeflateRect(1,1,1,1); pDC->FillSolidRect(&rcItem, m_pColor->GetDiagramLayoutActiveFillColor()); // 设置激活前景色 SetCellText(nCellIndex, nItemID, NULL, TEXT_COLOR_ACTIVEFIXEDNAME); } else { // 设置默认前景色 SetCellText(nCellIndex, nItemID, NULL, TEXT_COLOR_FIXEDNAME); } } else {// 不是资讯索引单元格 if (pos == CPoint(GetColCount()-1, 0)) {// 如果是第一行,最后一列 ////////////////////////////////////////////////////////////////////////// // 计算全屏或者还原图标区域 CalcImageRect(&m_rcMaxScreen, &rcItem, TRUE); // 绘制图片 if (!m_bSizeMax) m_lstImage.Draw(pDC, 0, CPoint(m_rcMaxScreen.left, m_rcMaxScreen.top), ILD_TRANSPARENT); else m_lstImage.Draw(pDC, 4, CPoint(m_rcMaxScreen.left, m_rcMaxScreen.top), ILD_TRANSPARENT); ////////////////////////////////////////////////////////////////////////// // 计算关闭图标区域 CalcImageRect(&m_rcClose, &rcItem, FALSE); // 绘制图片 m_lstImage.Draw(pDC, 1, CPoint(m_rcClose.left, m_rcClose.top), ILD_TRANSPARENT); return TRUE; } else if (pos == CPoint(GetColCount()-1, 1)) { ////////////////////////////////////////////////////////////////////////// // 计算向上翻屏图标区域 CalcImageRect(&m_rcUp, &rcItem, TRUE); // 绘制图片 m_lstImage.Draw(pDC, 2, CPoint(m_rcUp.left, m_rcUp.top), ILD_TRANSPARENT); ////////////////////////////////////////////////////////////////////////// // 计算向下翻屏图标区域 CalcImageRect(&m_rcDown, &rcItem, FALSE); // 绘制图片 m_lstImage.Draw(pDC, 3, CPoint(m_rcDown.left, m_rcDown.top), ILD_TRANSPARENT); return TRUE; } } return FALSE; }
void CmtWiTextList::SetupTextListParam(CmtPoint cellSize, uint32 gap, uint32 curCellPos) { if( mAddEnable ) { //Добавление разрешено, инициализировать список отображения Alloc( mStringCount + 1 ); //Установить указатели на строки буфера uint32 k = 0; for( uint32 i = 0; i < mPos; i++ ) { //Указатель на добавляемую строку cpchar ptr = (cpchar)(mBuffer.Buffer() + i); //Добавить строку SetCellText( k++, ptr ) ; i += strlen( ptr ); } //Последняя строка нулевая SetCellText( mStringCount, 0 ); //Все строки добавлены, установить параметры SetupTextPtrParam( cellSize, gap, curCellPos ); //Заблокировать последующее добавление строк mAddEnable = false; } }
void CDrawRFinance::OnUpdateFinaceData() { // 数据更新从第二列开始 int index = m_ayCell.GetCount() / 2; char strText[64]; memset(strText, 0, sizeof(strText)); for (int i = 0; i < m_ayTitleInt.GetCount(); i++, index++) { int nIndex = m_ayTitleInt.GetAt(i); CHSCalculate::GetTextByID(nIndex, &m_ayFinanceData.GetAt(0), strText); SetCellText(index, 0, strText, 0, 0, 0, 0, FALSE); } InValidate(&GetTableRect(), FALSE); }
//--------------------------------------------------------------------------- void __fastcall TSpreadSheetRLForm::FormShow(TObject *Sender) { cxSpreadBook->BeginUpdate(); // turn off updates try { cxSpreadBook->AutoRecalc = false; // turn off automatic recalculation cxSpreadBook->ActiveSheet->Caption = "Current"; // set the page caption for the first page cxSpreadBook->AddSheetPage("HiLo"); // and a second page and set it's caption cxSpreadBook->ActivePage = 0; // turn our attention to the first page SetCellText(0, 0,"Current Stockholding Valuations"); // set a title in the first column, first row cell SetCellText(0, 2,"Company"); // Col A - Set column titles SetCellText(1, 2,"Holding"); // B SetCellText(2, 2,"Purchased"); // C SetCellText(3, 2,"Price"); // D SetCellText(4, 2,"Cost"); // E = B * D SetCellText(5, 2,"Value"); // F SetCellText(6, 2,"Worth"); // G = B * F SetCellText(7, 2,"Gain"); // H = G - E SetCellText(8, 2,"%age Gain"); // I = H / E cxSpreadBook->ActivePage = 1; // over now to the second page SetCellText(0, 0, "High, Low and Current Stock Prices"); // and repeat the process SetCellText(0,2,"Company"); // Col A SetCellText(1,2,"Price"); // B SetCellText(2,2,"High"); // C SetCellText(3,2,"Low"); // D SetCellText(4,2,"Average"); // E cxSpreadBook->AutoRecalc = true; // autorecalc back on cxSpreadBook->ActivePage = 0; // and back to the first page cxSpreadBookSetSelection(NULL, cxSpreadBook->ActiveSheet); // call to set the current cell and cell contents display } __finally { cxSpreadBook->EndUpdate(); } }
//--------------------------------------------------------------------------- void __fastcall TSpreadSheetRLForm::actLoadDataExecute(TObject *Sender) { TCursor CurCursor; CurCursor = Screen->Cursor; // preserve the current one Screen->Cursor = crHourGlass; // wait cursor try { cxSpreadBook->BeginUpdate(); // turn off updates cxSpreadBook->ActivePage = 0; // ensure we are looking at the right page FCurRow = 3; // set the starting current row MemData->Open(); // open the data while (!MemData->Eof) { SetCellText(0, FCurRow, // set the company name MemData->FieldByName("CO_NAME")->AsString); SetCellText(1,FCurRow, // the number of shares MemData->FieldByName("SHARES")->AsString); SetCellDate(2,FCurRow, // the purchase date MemData->FieldByName("PUR_DATE")->AsDateTime); SetCellText(3,FCurRow, // the purchase price MemData->FieldByName("PUR_PRICE")->AsString); SetCellText(4,FCurRow, // calculate the purchase cost = number of shares * purchase price Format(AnsiString("=B%d*D%d/100"), ARRAYOFCONST((FCurRow + 1, FCurRow + 1)))); // [FCurRow+1,FCurRow+1])); SetCellText(5,FCurRow, // the current price MemData->FieldByName("CUR_PRICE")->AsString); SetCellText(6,FCurRow, // calculate the current valuation = number of shares * current price Format(AnsiString("=B%d*F%d/100"), ARRAYOFCONST((FCurRow + 1, FCurRow + 1)))); SetCellText(7,FCurRow, // calculate the gain/loss = current valuation - purchase cost Format(AnsiString("=G%d-E%d"),ARRAYOFCONST((FCurRow + 1, FCurRow + 1)))); SetCellText(8,FCurRow, // calculate the %age gain/loss Format(AnsiString("=H%d/E%d"),ARRAYOFCONST((FCurRow+1,FCurRow+1)))); MemData->Next(); // and the next record FCurRow++; // and bump the row number } FCurRow++; SetCellText(4, FCurRow, // set the formula for the total purchase cost Format(AnsiString("=SUM(E3:E%d)"),ARRAYOFCONST((FCurRow - 1)))); SetCellText(6, FCurRow, // total current valuation Format(AnsiString("=SUM(G3:G%d)"), ARRAYOFCONST((FCurRow - 1)))); SetCellText(7, FCurRow, // total gain/loss Format(AnsiString("=SUM(H3:H%d)"),ARRAYOFCONST((FCurRow - 1)))); SetCellText(8, FCurRow, // and overall percentage Format(AnsiString("=H%d/E%d"), ARRAYOFCONST((FCurRow + 1, FCurRow + 1)))); MemData->First(); // back to the first record cxSpreadBook->ActivePage = 1; // and move to the second page // and repeat the process to setup the data FCurRow = 3; while(!MemData->Eof){ SetCellText(0,FCurRow, // company name MemData->FieldByName("CO_NAME")->AsString); SetCellText(1,FCurRow, // current price MemData->FieldByName("CUR_PRICE")->AsString); SetCellText(2,FCurRow, // year high MemData->FieldByName("YRL_HIGH")->AsString); SetCellText(3,FCurRow, // year low MemData->FieldByName("YRL_LOW")->AsString); SetCellText(4,FCurRow, // average of Hi/Lo prices Format(AnsiString("=(C%d+D%d)/2"), ARRAYOFCONST((FCurRow + 1, FCurRow + 1)))); MemData->Next(); FCurRow++; } FCurRow++; MemData->Close(); FIsApplyFormatting = true; // enable the formatting button } __finally { cxSpreadBook->EndUpdate(); // turn update back on cxSpreadBook->Recalc(); // auto recalc on cxSpreadBook->ActivePage = 0; // back to first page Screen->Cursor = CurCursor; // and back to default cursor } }