本文整理汇总了C++中CArray::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::SetSize方法的具体用法?C++ CArray::SetSize怎么用?C++ CArray::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::SetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
void ProcessForm::OnLvnColumnclickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
int Length = m_listCtrl.GetItemCount();
CArray<CString,CString> ItemData;
ItemData.SetSize(Length);
for (int i = 0; i < Length; i++)
{
ItemData[i] = m_listCtrl.GetItemText(i,pNMLV->iSubItem);
m_listCtrl.SetItemData(i,(DWORD_PTR)&ItemData[i]);//设置排序关键字
}
static int sort = 0;
static int SubItem = 0;
if (SubItem != pNMLV->iSubItem)
{
sort = 0;
SubItem = pNMLV->iSubItem;
}
else
{
sort = 1 - sort;
}
if(SubItem == 1) isNum = true;
else isNum = false;
m_listCtrl.SortItems(MyCompareProc,(DWORD_PTR)&sort);//排序
*pResult = 0;
}
示例3: 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.
}
示例4: ChangeMasterColumn
//Private
BOOL COXMultiComboBox::ChangeMasterColumn(int /* nCol */)
{
int nNumItems = GetCount();
CArray<COXRowData*,COXRowData*> aPtrsRowData;
aPtrsRowData.SetSize(nNumItems);
int nIndex=0;
for(nIndex=0; nIndex < nNumItems; nIndex++)
{
COXRowData* pRowData = GetRowData(nIndex);
aPtrsRowData[nIndex] = pRowData;
if (pRowData == NULL)
TRACE0("In COXMultiComboBox::ChangeMasterColumn : GetRowData() returned NULL.\n");
}
// ... To avoid deleting the Rowdata in DeleteItem
m_fMasterColumnChanging = TRUE;
// ... Delete all the Items
ResetContent();
// ... Resets the flag
m_fMasterColumnChanging = FALSE;
int nRetVal;
// Again add all the items. This deletion and addition is to effect
// the sorting order based on current master column
for(nIndex=0; nIndex < nNumItems; nIndex++)
{
if((nRetVal = CComboBox::AddString((aPtrsRowData[nIndex])->GetColumnString(m_nMasterColumn))) != CB_ERR)
SetRowData(nRetVal,aPtrsRowData[nIndex]);
else
return FALSE;
}
return TRUE;
}
示例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: DoTestFiles
void DoTestFiles(const char *filelist, const char *environment)
{
if (!GetTestFiles(filelist)) {
printf("No Files to test!\r\n");
return;
}
Results.SetSize(IsapiFileList.GetSize());
ReadGlobalEnvironment(environment);
DoThreads();
printf("\r\nRESULTS:\r\n");
// show results:
DWORD r = Results.GetSize();
for (DWORD i=0; i< r; i++) {
TResults result = Results.GetAt(i);
printf("%s\r\nOK: %d FAILED: %d\r\n", TestNames.GetAt(i), result.ok, result.bad);
}
// delete temp files
printf("Deleting Temp Files\r\n");
DeleteTempFiles("exp.*");
DeleteTempFiles("pht.*");
printf("Done\r\n");
}
示例7: ReadLine
bool SgmlFile::ReadLine(BYTE *aBuffer, int iBufferLength, int *piReadPointer, CString &csLine, UINT nCodepage) {
bool bSuccess = true;
if (aBuffer == NULL || iBufferLength <= 0)
bSuccess = false;
if (bSuccess && (*piReadPointer >= iBufferLength))
bSuccess = false;
CArray<BYTE, BYTE> aLineBytes;
aLineBytes.SetSize(0, 500);
bool bBreakFound = false;
if (bSuccess) {
bSuccess = GetNextLineFromBuffer(aBuffer, aLineBytes, *piReadPointer,
iBufferLength, bBreakFound);
}
if (bSuccess && !bBreakFound)
bSuccess = false;
if (bSuccess)
bSuccess = ConvertBufferToString(aLineBytes, csLine, nCodepage);
return bSuccess;
}
示例8: 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
示例9: EqualizeColors
void CTreemap::EqualizeColors(const COLORREF *colors, int count, CArray<COLORREF, COLORREF&>& out)
{
out.SetSize(count);
for (int i=0; i < count; i++)
{
out[i] = CColorSpace::MakeBrightColor(colors[i], PALETTE_BRIGHTNESS);
}
}
示例10: MoveTo
int CReportCtrl::MoveTo(int nItem, int nNewPosition)
{
if(!_IsValidIndex(nItem))
{
return(-1);
}
EndEdit(TRUE);
const int ITEMS = CListCtrl :: GetItemCount();
nNewPosition = max(0, nNewPosition);
nNewPosition = min(ITEMS - 1, nNewPosition);
if(nItem == nNewPosition)
{
return(nNewPosition);
}
_UnsetSortedColumn();
// Backup all states and attributes
const int COLS = GetColumnCount();
const DWORD STATES = GetItemStates(nItem);
const DWORD DATA = CListCtrl :: GetItemData(nItem);
CArray<int, int> aImages;
CStringArray aTexts;
aImages.SetSize(COLS);
aTexts.SetSize(COLS);
for(int i = 0; i < COLS; i++)
{
aImages[i] = GetItemImage(nItem, i);
aTexts[i] = GetItemText(nItem, i);
}
// Delete the item
CListCtrl :: DeleteItem(nItem);
// Insert a new item to the new position
const int IDX = CListCtrl :: InsertItem(nNewPosition, _T(""));
// Restore all states & attributes to the newly inserted item
for(int j = 0; j < COLS; j++)
{
CListCtrl :: SetItemText(IDX, j, aTexts[j]);
SetItemImage(IDX, j, aImages[j]);
}
CListCtrl :: SetItemData(IDX, DATA);
SetItemStates(IDX, STATES);
return(IDX);
}
示例11: 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);
}
示例12: GetDefaultPalette
void CTreemap::GetDefaultPalette(CArray<COLORREF, COLORREF&>& palette)
{
if (CColorSpace::Is256Colors())
{
palette.SetSize(countof(_defaultCushionColors256));
for (int i=0; i < countof(_defaultCushionColors256); i++)
palette[i]= _defaultCushionColors256[i];
// We don't do
//EqualizeColors(_defaultCushionColors256, countof(_defaultCushionColors256), palette);
// because on 256 color screens, the resulting colors are not distinguishable.
}
else
{
EqualizeColors(_defaultCushionColors, countof(_defaultCushionColors), palette);
}
}
示例13: 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();
}
示例14: 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();
//关闭剪贴板,释放剪贴板资源的占用权
}
//--------------------------------------------------------------------------------------------------------------------
}
示例15: DeleteOldAndHighlightNew
// This is a little tricky. We need to delete the current selection,
// while highlighting the newly dropped items, without letting them
// screw each other's indices up.
// We know that the newly dropped items are in a contiguous block,
// which helps.
void OleListCtrl::DeleteOldAndHighlightNew()
{
// First, get a reverse-order list of selected items,
// which will be deleted.
CArray <int, int> anSelectedItems;
anSelectedItems.SetSize( 0, 50 );
int nA = -1;
while ( ( nA = GetNextItem( nA, LVNI_SELECTED ) ) != -1 )
{
anSelectedItems.Add( nA );
}
UnselectAll();
// Now select the dropped items.
std::vector<int>::iterator it;
for ( it = m_vnNewlyDroppedItems.begin(); it != m_vnNewlyDroppedItems.end(); ++it )
{
SetItemState( (*it), LVIS_SELECTED, LVIS_SELECTED );
}
// Now step through the deleted items, deleting.
// We track the first newly dropped item as we go.
int nFirst = m_vnNewlyDroppedItems[0];
for ( nA = anSelectedItems.GetUpperBound(); nA >= 0; nA-- )
{
// There should be no overlap here!
ASSERT( anSelectedItems[nA] != m_vnNewlyDroppedItems[0] );
DeleteItem( anSelectedItems[nA], false );
// Track the first slot as it slides up.
if ( anSelectedItems[nA] < nFirst )
nFirst--;
}
if ( nFirst >= 0 )
{
SetItemState( nFirst, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
}
m_vnNewlyDroppedItems.clear();
}