本文整理汇总了C++中CArray::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::GetData方法的具体用法?C++ CArray::GetData怎么用?C++ CArray::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadPersistentAttributes
void CSortingListControl::LoadPersistentAttributes()
{
CArray<int, int> arr;
arr.SetSize(GetHeaderCtrl()->GetItemCount());
GetColumnOrderArray(arr.GetData(), arr.GetSize());
CPersistence::GetColumnOrder(m_name, arr);
SetColumnOrderArray(arr.GetSize(), arr.GetData());
for (int i=0; i < arr.GetSize(); i++)
arr[i]= GetColumnWidth(i);
CPersistence::GetColumnWidths(m_name, arr);
for (i=0; i < arr.GetSize(); i++)
{
// To avoid "insane" settings we set the column width to
// maximal twice the default width.
int maxWidth= GetColumnWidth(i) * 2;
int w= min(arr[i], maxWidth);
SetColumnWidth(i, w);
}
// Not so good: CPersistence::GetSorting(m_name, GetHeaderCtrl()->GetItemCount(), m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2);
// We refrain from saving the sorting because it is too likely, that
// users start up with insane settings and don't get it.
}
示例2: 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());
}
示例3: Execute
TTaskResult CBeep::Execute(CRobot * Robot, CExecutableRWGraphicObjectList * ExecutableObjectList, bool & result)
{
if (Robot->GetSoftwareRevision() <= 1.06) /*Do the tune as beeps for robots before version 1.07*/
{
Robot->AddBeepToInstructions(GetFrequency(), GetDuration());
CFlowZap *FZ = (CFlowZap*)m_fc;
CBeep* LastBeep = this;
CInstruction *Next = FZ->GetNextInstructionInList(this);
// Next = FZ->GetNextExecutableInstruction(Next);
while (Next->IsKindOf(RUNTIME_CLASS(CBeep)))
{
LastBeep = (CBeep*)Next;
Robot->AddBeepToInstructions(LastBeep->GetFrequency(), LastBeep->GetDuration());
Next = FZ->GetNextInstructionInList(Next);
// Next = FZ->GetNextExecutableInstruction(Next);
}
FZ->SetCueToInstruction(LastBeep);
FZ->RedrawWindow();
}
else
{
unsigned int NumberOfNotes = 1;
CArray<short, short> FrequencyList;
FrequencyList.SetSize(20, 20);
CArray<int, int> DurationList;
DurationList.SetSize(20, 20);
FrequencyList[0] = GetFrequency();
DurationList[0] = GetDuration();
CFlowZap *FZ = (CFlowZap*)m_fc;
CBeep* LastBeep = this;
CInstruction *Next = FZ->GetNextInstructionInList(this);
// Next = FZ->GetNextExecutableInstruction(Next);
while (Next->IsKindOf(RUNTIME_CLASS(CBeep)))
{
LastBeep = (CBeep*)Next;
FrequencyList[NumberOfNotes] = LastBeep->GetFrequency();
DurationList[NumberOfNotes] = LastBeep->GetDuration();
NumberOfNotes++;
Next = FZ->GetNextInstructionInList(Next);
// Next = FZ->GetNextExecutableInstruction(Next);
}
FrequencyList[NumberOfNotes] = -1;
DurationList[NumberOfNotes] = 0;
NumberOfNotes++;
Robot->AddTuneToInstructions(FrequencyList.GetData(), DurationList.GetData(), NumberOfNotes);
FZ->SetCueToInstruction(LastBeep);
FZ->RedrawWindow();
}
TTaskResult TaskResult;
TaskResult = Robot->FollowInstructions(true, true, IR_InstructionComplete);
return TaskResult;
}
示例4: ConvertReceivedDataToString
CString ConvertReceivedDataToString(CByteArray & data)
{
// data is UTF-8 encoded
CArray<WCHAR, WCHAR> wc;
// First, compute the amount of space required. n will include the
// space for the terminal NUL character
INT_PTR n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), NULL, 0);
if(n == 0)
{ /* failed */
DWORD err = ::GetLastError();
TRACE(_T("%s: MultiByteToWideChar (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
return CString(_T(""));
} /* failed */
else
{ /* success */
wc.SetSize(n);
n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), (LPWSTR)wc.GetData(), (int)n);
if(n == 0)
{ /* failed */
DWORD err = ::GetLastError();
TRACE(_T("%s: MultiByteToWideChar (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
return CString(_T(""));
} /* failed */
} /* success */
// Data is now in Unicode
// If we are a Unicode app we are done
// If we are an ANSI app, convert it back to ANSI
#ifdef _UNICODE
// If this is a Unicode app we are done
return CString(wc.GetData(), (int)wc.GetSize());
#else // ANSI
// Invert back to ANSI
CString s;
n = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wc.GetData(), (int)wc.GetSize(), NULL, 0, NULL, NULL);
if(n == 0)
{ /* failed */
DWORD err = ::GetLastError();
TRACE(_T("%s: WideCharToMultiByte (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
return CString("");
} /* failed */
else
{ /* success */
LPSTR p = s.GetBuffer((int)n);
n = ::WideCharToMultiByte(CP_ACP, 0, wc.GetData(), (int)wc.GetSize(), p, (int)n, NULL, NULL);
if(n == 0)
{ /* conversion failed */
DWORD err = ::GetLastError();
TRACE(_T("%s: WideCharToMultiByte (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
s.ReleaseBuffer();
return CString("");
} /* conversion failed */
s.ReleaseBuffer();
return s;
} /* success */
#endif
} // ConvertReceivedDataToString
示例5: OnOK
void CMultiSelDlg::OnOK()
{
// now copy selection to the selection strings
CString strSel;
if(m_bSingleSelect)
{
int iSel = m_tListBox.GetCurSel();
if(iSel>=0)
{
m_tListBox.GetText(iSel, strSel);
m_astrStringsSel.Add(strSel);
}
}
else
{
CArray<int,int> aiListBoxSel;
int iCount = m_tListBox.GetSelCount();
aiListBoxSel.SetSize(iCount);
m_tListBox.GetSelItems(iCount, aiListBoxSel.GetData());
for(int iSel = 0; iSel < iCount; ++iSel)
{
m_tListBox.GetText(aiListBoxSel[iSel], strSel);
m_astrStringsSel.Add(strSel);
}
}
CDialog::OnOK();
}
示例6: 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();
}
}
示例7: SavePersistentAttributes
void CSortingListControl::SavePersistentAttributes()
{
CArray<int, int> arr;
arr.SetSize(GetHeaderCtrl()->GetItemCount());
GetColumnOrderArray(arr.GetData(), arr.GetSize());
CPersistence::SetColumnOrder(m_name, arr);
for (int i=0; i < arr.GetSize(); i++)
arr[i]= GetColumnWidth(i);
CPersistence::SetColumnWidths(m_name, arr);
// Not so good: CPersistence::SetSorting(m_name, m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2);
}
示例8: Read
BOOL CFormStreamReader::Read(void *pv, ULONG cb, ULONG *pcbRead)
{
if(pv == NULL) return FALSE;
if(pcbRead == NULL) return FALSE;
CArray<BYTE, BYTE> *pBuffer = m_pForm->GetBuffer();
*pcbRead = min(cb, pBuffer->GetCount() - m_pos);
memcpy(pv, &pBuffer->GetData()[m_pos], *pcbRead);
m_pos += *pcbRead;
return (m_pos >= (ULONG)pBuffer->GetCount()) ? FALSE : TRUE;
}
示例9: ConvertBufferToString
bool SgmlFile::ConvertBufferToString(CArray<BYTE, BYTE> &aLineBytes, CString &csLine, UINT nCodepage) {
bool bSuccess = true;
if (aLineBytes.GetSize() > 0) {
#ifdef _UNICODE
WCHAR *wszLine = new WCHAR[aLineBytes.GetSize() + 1];
int iChars = ::MultiByteToWideChar(nCodepage, 0, (const char *)aLineBytes.GetData(),
aLineBytes.GetSize(), wszLine, aLineBytes.GetSize());
wszLine[iChars] = 0;
// TODO what about the data already being Unicode? And in the wrong order?
csLine = wszLine;
delete[] wszLine;
#else
aLineBytes.Add(0);
csLine = aLineBytes.GetData();
#endif
} else
// at least a \n was found (empty line)
csLine.Empty();
return bSuccess;
}
示例10: OnOK
void CRemoveChannelsDlg::OnOK()
//-----------------------------
{
int nCount = m_RemChansList.GetSelCount();
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
m_RemChansList.GetSelItems(nCount, aryListBoxSel.GetData());
m_bKeepMask.assign(m_nChannels, true);
for (int n = 0; n < nCount; n++)
{
m_bKeepMask[aryListBoxSel[n]] = false;
}
if ((static_cast<UINT>(nCount) == m_nRemove && nCount > 0) || (m_nRemove == 0 && (m_pSndFile->GetNumChannels() >= nCount + m_pSndFile->GetModSpecifications().channelsMin)))
CDialog::OnOK();
else
CDialog::OnCancel();
}
示例11: OnBnClickedCopy
void CCommunicationTrafficDlg::OnBnClickedCopy()
{
//--------------------------------------------------------------------------------------------------------------------
CArray <int, int> aryListSel;
int nCount= m_DataList.GetSelCount();
aryListSel.SetSize(nCount);
m_DataList.GetSelItems(nCount, aryListSel.GetData());
// aryListSel中存的就是选中列的index值,如果需要取内容,加以下语句:
CString str,content;
for (int i= nCount-1; i>= 0; i--)
{
m_DataList.GetText(aryListSel.GetAt(i), (CString&)str);
str+=_T("\n");
content==str;
}
//--------------------------------------------------------------------------------------------------------------------
HGLOBAL hClip;
//定义一个HGLOBAL句柄变量用来指向分配的内存块
if (OpenClipboard())
{
EmptyClipboard(); //将剪贴板内容清空
hClip=GlobalAlloc(GMEM_MOVEABLE,content.GetLength()+1);
//在堆上分配可移动的内存块,程序返回一个内存句柄
char * buff; //定义指向字符型的指针变量
buff=(char*)GlobalLock(hClip);
//对分配的内存块进行加锁,将内存块句柄转化成一个指针,并将相应的引用计数器加1
strcpy(buff,(char*)content.GetBuffer());
//将用户输入的数据复制到指针变量中,实际上就是复制到分配的内存块中
GlobalUnlock(hClip);
//数据写入完毕,进行解锁操作,并将引用计数器数字减1
SetClipboardData(CF_TEXT,hClip);
//将存放有数据的内存块放入剪贴板的资源管理中
CloseClipboard();
//关闭剪贴板,释放剪贴板资源的占用权
}
//--------------------------------------------------------------------------------------------------------------------
}
示例12: OnSelectPassenger
void CSelectPassenger::OnSelectPassenger()
{
int selCount = listboxPassenger.GetSelCount();
CArray<PassengerInfo>& passlist = CConfig::GetConfig().GetPassenger();
CArray<int> selectedIndex;
selectedIndex.SetSize(selCount);
listboxPassenger.GetSelItems(selCount, selectedIndex.GetData());
for(int i = 0; i < passlist.GetCount(); i++)
{
for(int j = 0; j < selectedIndex.GetCount(); j++)
{
CString str;
listboxPassenger.GetText(selectedIndex[j], str);
if(passlist[i].name == str)
{
selectedpass.Add(passlist[i]);
}
}
}
}
示例13: UpdateChart
void CChartDlg::UpdateChart()
{
// Get the indexes of all the selected items.
int nCount = m_Datasel.GetSelCount();
if(nCount <= 0)
return;
UpdateData();
m_Chart.ClearAll();
m_Chart.SetAxis(m_dBase+5.0*m_dVary,m_dBase-5.0*m_dVary,m_dBase,m_dVary*4.0);
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
m_Datasel.GetSelItems(nCount, aryListBoxSel.GetData());
int nTotal = nCount;
CString sCurr;
while(nCount > 0)
{
m_Datasel.GetText(nTotal-nCount--,sCurr);
m_Chart.AddData(atof(sCurr));
}
}
示例14: OnBnClickedAutoupdate
void CChartDlg::OnBnClickedAutoupdate()
{
// TODO: 在此添加控件通知处理程序代码
//auto size the chart
int nCount = m_Datasel.GetSelCount();
if(nCount <= 0)
return;
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
m_Datasel.GetSelItems(nCount, aryListBoxSel.GetData());
int nTotal = nCount;
CString sCurr;
double new_base=0;
while(nCount > 0)
{
m_Datasel.GetText(nTotal-nCount--,sCurr);
new_base += atof(sCurr);
}
new_base = new_base/nTotal;
nCount = nTotal;
double new_vary=0;
while(nCount > 0)
{
m_Datasel.GetText(nTotal-nCount--,sCurr);
new_vary += (atof(sCurr)-new_base)*(atof(sCurr)-new_base);
}
new_vary = sqrt(new_vary/nTotal);
m_dBase = new_base;
m_dVary = new_vary;
UpdateData(FALSE);
UpdateChart();
}
示例15: main
void main()
{
CArray arr;
arr.Add(1234);
arr.Add(23);
arr.Add(44);
arr.Add(21);
arr.Add(5);
arr.RemoveAt(2,20000000); //从第二个位置起,删除2个数据
arr.InsertAt(3,10,2);
int i = 0;
int nSize = arr.GetSize();
cout << "共有 " << nSize << " 条数据" << endl;
TYPE *p = arr.GetData();
qsort(p,nSize,sizeof(TYPE),compar);
while(i < nSize)
{
cout << arr[i] << endl;
++i;
}
}