本文整理汇总了C++中CArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::Add方法的具体用法?C++ CArray::Add怎么用?C++ CArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPreparePrinting
BOOL CCollegeTimeTableView::OnPreparePrinting(CPrintInfo* pInfo)
{pInfo->SetMinPage(1);
CString temp,temp2;
CStringArray arr;
arr.SetSize(20); //// for parallel lecture splitting in diff strings
int height,maxheight;
int LineCounter=0,PageIndex=0;
PageArray.RemoveAll(); ////// Reset Page Description Array
CPage tempage;
PageArray.Add(tempage);
BOOL bLastEmpty=FALSE;
for(int i=1;i<ROWS;i++) ////// Preapre Page Description
{maxheight=1;
temp=m_master.GetItemText(i,0);
if(temp.IsEmpty()){ if(i+1<ROWS) { temp2=m_master.GetItemText(i+1,0);
if(temp2[0]>='0' && temp2[0]<='9')
continue;///no blank line before time cell
///since onprint() will create one
}
if(bLastEmpty) continue; /// keep atmost one empty row
if((LineCounter+1)<LinesPerPage)
{LineCounter++;
PageArray[PageIndex].Line.Add(i);
bLastEmpty=TRUE;
continue;
}
else
{PageIndex++;
PageArray.Add(tempage);
LineCounter=0;
continue;
}
}
bLastEmpty=FALSE;
GetParallelLectureList(temp,arr);// Get Parallel lectures in CStringarray arr
height=arr.GetSize();
if(height<1) height=1;
if(height>maxheight) maxheight=height; ///max cell height,>1 for parallel lectures
if((LineCounter+maxheight)<LinesPerPage)
{LineCounter+=maxheight; //include lines
PageArray[PageIndex].Line.Add(i); continue; ///go for more lines
}
PageIndex++; /// Page Full, go for next page
PageArray.Add(tempage);///Create Empty Page Struct
LineCounter=maxheight; ///
PageArray[PageIndex].Line.Add(i);
}
pInfo->SetMaxPage(PageIndex+1);
return DoPreparePrinting(pInfo);
}
示例2: OnTabColor
void CMServerManagerView::OnTabColor()
{
UpdateData();
CArray<COLORREF, COLORREF> arColors;
arColors.Add(RGB (121, 210, 231));
arColors.Add(RGB (190, 218, 153));
arColors.Add(RGB (255, 170, 100));
m_mfcTab.EnableAutoColor(TRUE);
m_mfcTab.SetAutoColors(arColors);
}
示例3: GetCanCardListAvailable
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
tcCanDll::tcCanDll(tcParamCan* pParamCan)
{
m_pParam = NULL;
// Create Can session
int CardNumber = 0;
CString Err;
CString FullError;
CArray<CString,CString> CanCardList;
// Search Can card
if (strcmp(pParamCan->CanCardName,cCanCardAUTOMATIC) == 0)
{
char Buffer[MAX_PATH];
for(U8 i=0;i<GetCanCardListAvailable(0,NULL);i++)
{
GetCanCardListAvailable(i,Buffer);
// Remove ADLink card in Automatic research because it open DialogBox
if (strncmp(pParamCan->CanCardName,cCanCardADLINK,sizeof(cCanCardADLINK)-1))
{
CanCardList.Add(Buffer);
}
}
}
else
{
CanCardList.Add(pParamCan->CanCardName);
}
while((CardNumber < CanCardList.GetSize()) && (m_pParam == NULL))
{
strcpy(pParamCan->CanCardName,CanCardList[CardNumber]);
if ((strcmp(pParamCan->CanCardName,cCanCardVIRTUAL) != 0) // Pass cCanCardVIRTUAL if not first
||(CardNumber == 0))
{
if (strcmp(pParamCan->CanCardName,cCanCardAUTOMATIC) != 0) // Pass cCanCardAUTOMATIC
{
m_pParam = GetCanCard(pParamCan,Err);
if (m_pParam == NULL)
{
FullError += Err;
FullError += '\n';
}
}
}
CardNumber++;
}
if((pParamCan->FCallBackMsg != NULL) && (m_pParam == NULL)) // Can card not found
{
pParamCan->FCallBackMsg(cErrorMsg,FullError,pParamCan->ParamCallBackMsg);
}
}
示例4: OnDrawFace
void CSkyODL::OnDrawFace( Gdiplus::Graphics& gcDrawer, float fScale )
{
CBaseODL::OnDrawFace(gcDrawer, fScale);
Gdiplus::Pen Dot( m_clDotColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
CArray<Gdiplus::Point> st;
CArray<BYTE> stBytes;
for (auto& curItem : m_arrTopPoint)
{
Gdiplus::Point pt;
pt.X = static_cast<INT>(curItem.X());
pt.Y = static_cast<INT>(-curItem.Z());
st.Add(pt);
}
if(st.GetSize()<=0)
{
return;
}
Gdiplus::Pen pen( m_clPenColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
pen.SetDashStyle(Gdiplus::DashStyleSolid);
Gdiplus::HatchBrush brush( Gdiplus::HatchStyle(Gdiplus::HatchStyle::HatchStyleCross ), m_clPenColor, Gdiplus::Color(0,255,255,255) );
//画皮肤
gcDrawer.FillPolygon(&brush, st.GetData(), st.GetSize(), Gdiplus::FillMode::FillModeAlternate);
gcDrawer.DrawLines(&pen, st.GetData(), st.GetSize());
}
示例5: GetSelectionList
void CurveDesigGridCell::GetSelectionList(CStringArray& aText, CArray<bool,bool>& aEnable)
{
aText.RemoveAll();
aEnable.RemoveAll();
for (int i = 0; i < TestZoneCurveGridCtrl::curveFileDesigStrings.Size(); i++)
{
aText.Add(TestZoneCurveGridCtrl::curveFileDesigStrings[i]);
aEnable.Add(true);
}
if (TestZoneCurveGridCtrl::curveFileDesigStrings.IsEmpty())
{
aText.Add("no file set");
aEnable.Add(false);
}
}
示例6: BusInfoQueryRight
int BusInfoQueryRight(CArray<rowItem, rowItem> &rest)
{
int index = 0;
for(index = 0; index<(sizeof(Table)/sizeof(Table[0])); index++){
if(Table[index].name.Compare(_T("bus")) == 0)
break;
}
struct query query;
query.from = _T("bus");
query.selectedItemCount = Table[index].itemKeyCount + Table[index].itemOthersCount;
for(int i = 0; i<query.selectedItemCount; i++){
query.SI[i].name = Table[index].fieldValue[i].fieldName;
query.SI[i].chineseName = Table[index].fieldValue[i].chineseName;
}
query.whereItemCount = 0;
query.otherTerm = _T("");
Query(&query, rest);
if(rest.GetCount() == 0){
rowItem temp;
temp.fieldCount = Table[index].itemKeyCount + Table[index].itemOthersCount;
for(int i = 0; i<temp.fieldCount; i++){
temp.CI[i].chineseName = Table[index].fieldValue[i].chineseName;
temp.CI[i].name = Table[index].fieldValue[i].fieldName;
temp.CI[i].valueType = Table[index].fieldValue[i].fieldType;
}
rest.Add(temp);
}
return TRUE;
}
示例7: ScanFile
void MusicUtils::ScanFile(CString Dir,CArray<CString,CString&>& filearray,CString filetype)
{
CFileFind finder;
CString Add=L"\\*";
CString DirSpec=Dir+Add; //补全要遍历的文件夹的目录
BOOL bWorking = finder.FindFile(DirSpec);
while (bWorking)
{
bWorking = finder.FindNextFile();
if(!finder.IsDots()) //扫描到的不是节点
{
if(finder.IsDirectory()) //扫描到的是文件夹
{
CString strDirectory = finder.GetFilePath();
ScanFile(strDirectory,filearray,filetype); //递归调用ScanFile()
}
else //扫描到的是文件
{
CString strFile = finder.GetFilePath(); // 得到文件的全路径
CString ext = GetFileTitleFromFileName(strFile).MakeLower();
if (ext==CString("bmp"))
{
filearray.Add(strFile);
}
//进行一系列自定义操作
}
}
}
finder.Close();
}
示例8: OnDbTogglebreakpoint
void CDebuggerView::OnDbTogglebreakpoint()
{
int pos = m_editor.SendEditor(SCI_GETCURRENTPOS);
int lineNumber = m_editor.SendEditor(SCI_LINEFROMPOSITION, pos);
// Is there a breakpoint currently here?
int breakpointIndex = FindBreakpoint(m_currentFileName, lineNumber);
if (breakpointIndex == -1)
{
// No, add it.
m_editor.SendEditor(SCI_MARKERDEFINE, MARKER_BREAKPOINT, SC_MARK_CIRCLE);
m_editor.SendEditor(SCI_MARKERSETFORE, MARKER_BREAKPOINT, RGB(0x00, 0x00, 0));
m_editor.SendEditor(SCI_MARKERSETBACK, MARKER_BREAKPOINT, RGB(0xff, 0x00, 0x00));
m_editor.SendEditor(SCI_MARKERADD, lineNumber, MARKER_BREAKPOINT);
// Add the breakpoint.
BreakpointInfo info;
info.m_fileName = m_currentFileName;
info.m_lineNumber = lineNumber;
m_breakpointInfo.Add(info);
}
else
{
// Remove the breakpoint.
m_editor.SendEditor(SCI_MARKERDELETE, lineNumber, MARKER_BREAKPOINT);
m_breakpointInfo.RemoveAt(breakpointIndex);
}
CString command;
command.Format(_T("DebugSetBreakpoint('%s',%d,%s)"), m_currentFileName, lineNumber,
(breakpointIndex == -1) ? _T("true") : _T("false"));
theApp.GetNetworkClient().SendCommand(command);
}
示例9: AddMissingFile
void CTemplateParserApp::AddMissingFile(CString csFile)
{
// unfortunately doesn't work: as FileExists() doesn't work
char szFileName[MAX_PATH*2];
strcpy (szFileName, (LPCTSTR)csFile);
CArray<CString, CString> nonExistant;
char *szSuffix = strrchr(szFileName, '\\');
while(NULL != szSuffix && !FileExists(szFileName))
{
// there must be at least one \ remaining in szFile (i.e. c:\)
CString csNono(szFileName);
// TODO: Wie geht denn das hier mit der Speicherverwaltung??
// Diese Variable ist doch nur auf dem Stack.
nonExistant.Add(csNono);
szSuffix[0] = '\0';
szSuffix = strrchr(szFileName, '\\');
}
if (nonExistant.GetSize() > 0)
{
for (int i=nonExistant.GetSize()-1; i>=0; --i)
{
m_writtenFiles.Add(nonExistant[i]);
// it is important that them are added in reverse order
// so that created directories are before the contained files
}
}
}
示例10: EnumDevices
int CCaptureVideo::EnumDevices(CArray<CString, CString>& arList)
{
int nCount = 0;
//枚举视频扑捉设备
ICreateDevEnum *pCreateDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR)return -1;
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
if (hr != NOERROR)return -1;
pEm->Reset();
ULONG cFetched;
IMoniker *pM;
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
{
IPropertyBag *pBag;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
char szStr[2048];
nCount++;
WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, szStr, 2048, NULL, NULL);
arList.Add( CString(szStr) );
SysFreeString(var.bstrVal);
pM->AddRef();
}
pBag->Release();
}
pM->Release();
}
return nCount;
}
示例11: guard
void SeriesValuesDialog::OnLvnKeydownList2(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
int i,n; POSITION pos; CArray<int,const int&> arr; CString temp; CString T,T1;
void *x; TChartSeries *graph;
switch(pLVKeyDow->wVKey)
{
case VK_DELETE:
if((x=Series->GainAcsess(WRITE))!=NULL)
{
SeriesProtector guard(x); TSeriesArray& series(guard);
graph=series[graph_num];
n=graph->GetSize();
pos=ListBox2.GetFirstSelectedItemPosition();
while(pos) arr.Add(ListBox2.GetNextSelectedItem(pos));
graph->SetParentUpdateStatus(UPD_OFF);
for(i=0;i<arr.GetSize();i++)
{
n=arr[i];
graph->RemoveAt(n-i);
ListBox2.DeleteItem(n-i);
}
graph->SetParentUpdateStatus(UPD_ON);
}
break;
}
*pResult = 0;
}
示例12: CreateEquilateralPolygon
// Tao da giac deu voi
// iIdentity > 2: nhan dang da giac deu, = 5: ngu giac deu, = 6: luc giac deu ...
// dAlpha: diem bat dau cua da giac deu co goc la dAlpha
// (x,y) tam cua da giac deu
// iRadius: ban kinh
// iColor: mau cua duong bien da giac deu
void _Polygon::CreateEquilateralPolygon(int iIdentity, double dAlpha, int x, int y, int iRadius, int iColor)
{
CString _strError("");
if (iIdentity <= 2)
{
_strError = "_Polygon::CreateEquilateralPolygon() --> iIdentity: Khong phai da giac";
iIdentity = 3;
}
CArray<POINT> arrTemp;
POINT temp;
double dAngle = 2*PI / iIdentity; // goc quay
// Tao cac dinh cua da giac deu
for (int i = 0; i < iIdentity; ++i)
{
temp.x = iRadius * cos(dAlpha + dAngle * i) + x;
temp.y = iRadius * sin(dAlpha + dAngle * i) + y;
arrTemp.Add(temp);
}
CreatePolygon(arrTemp, iColor);
strError += _strError; // Gan loi
}
示例13: OnDeleteSeries
void SeriesListCtrl::OnDeleteSeries()
{
POSITION pos=GetFirstSelectedItemPosition(); bool upd=false; void *x;
if(pos)
{
CArray<int,const int&> ToDel; int i; CString temp;
while(pos) ToDel.Add(GetItemData(GetNextSelectedItem(pos)));
qsort(ToDel.GetData(),ToDel.GetSize(),sizeof(int),compfunc);
for(i=0;i<ToDel.GetSize();i++)
{
int n=ToDel[i];
temp.Format("Series %s contains %d points. Remove it?",Items[n].Name,Items[n].Size);
if(AfxMessageBox(temp,MB_YESNO)==IDNO) ToDel[i]=-1;
}
if((x=Series->GainAcsess(WRITE))!=0)
{
upd=true;
SeriesProtector Protector(x); TSeriesArray& Series(Protector);
{
for(i=0;i<ToDel.GetSize();i++)
if(ToDel[i]>=0) Series.DeleteItem(ToDel[i]);
}
}
if(upd) UpdateSeriesList();
}
}
示例14: DeleteKey
void CRegistry::DeleteKey(HKEY hParent, LPCTSTR pszKey)
{
HKEY hKey;
if ( RegOpenKeyEx( hParent, pszKey, 0, KEY_ALL_ACCESS, &hKey ) ) return;
CArray< CString > pList;
for ( DWORD nIndex = 0 ; ; nIndex++ )
{
DWORD dwName = 64; // Input parameter in TCHARs
TCHAR szName[64];
LRESULT lResult = RegEnumKeyEx( hKey, nIndex, szName, &dwName, NULL, NULL, 0, NULL );
if ( lResult != ERROR_SUCCESS ) break;
szName[ dwName ] = 0;
pList.Add( szName );
DeleteKey( hKey, szName );
}
for ( int nItem = pList.GetSize() - 1 ; nItem >= 0 ; nItem-- )
{
RegDeleteKey( hKey, pList.GetAt( nItem ) );
}
if ( lstrlen( pszKey ) > 25 ) // Handle likely initial non-recursive value
RegDeleteKey( HKEY_CURRENT_USER, pszKey );
RegCloseKey( hKey );
}
示例15: win_ListBox_Select
int win_ListBox_Select (
char *title,
char **lines, // array of string descriptions
int num_lines ) // # in array
{
int i, selection;
// If only 1 line available, return index to this line
if (num_lines == 1)
selection = 0;
else {
// Allow user to select from a MFC dialog box
CArray <CString, CString> list;
for (i=0; i<num_lines; i++)
list.Add (lines[i]);
ListBox dialog (NULL, title);
dialog.SetContents (&list);
//ShowCursor (TRUE);
if (dialog.DoModal () != IDOK)
selection = -1;
else
selection = dialog.GetSelection ();
}
return (selection);
}