Click here to Skip to main content
15,902,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Update only a particial area of a View with UpdateAllViews(...) Pin
Bram van Kampen12-Jul-08 15:02
Bram van Kampen12-Jul-08 15:02 
QuestionRe: Update only a particial area of a View with UpdateAllViews(...) Pin
David Crow11-Jul-08 7:29
David Crow11-Jul-08 7:29 
AnswerRe: Update only a particial area of a View with UpdateAllViews(...) Pin
CrocodileBuck11-Jul-08 23:12
CrocodileBuck11-Jul-08 23:12 
QuestionRe: Update only a particial area of a View with UpdateAllViews(...) Pin
David Crow12-Jul-08 7:19
David Crow12-Jul-08 7:19 
GeneralRe: Update only a particial area of a View with UpdateAllViews(...) Pin
CrocodileBuck11-Jul-08 6:19
CrocodileBuck11-Jul-08 6:19 
QuestionHow to find ActiveX Control corresponding file in VC9? Pin
followait11-Jul-08 3:56
followait11-Jul-08 3:56 
QuestionCArray problem Pin
Trupti Mehta11-Jul-08 3:37
Trupti Mehta11-Jul-08 3:37 
AnswerRe: CArray problem Pin
Mark Salsbery11-Jul-08 4:59
Mark Salsbery11-Jul-08 4:59 
I tested your code as follows:
struct CStockEntry
{
	int entry;
	CStockEntry(int i = 0)  {entry = i;}
};

class DeptStock
{
public:
	CArray<CStockEntry, CStockEntry> stockArr;   

	void SetCStockEntryArr(CArray<CStockEntry, CStockEntry>& arr) 
	{   
		for (int i=0; i <= arr.GetUpperBound(); i++) 
		{   
			CStockEntry se = arr.GetAt(i);   
			this->stockArr.Add(se);   
		}   

		CString s1 = _T("Size of copied Array & Org:");   
		s1.Format(_T("%s %d %d"), s1, stockArr.GetSize(), arr.GetSize());  // This shows same number of arr & stockArr GetSize 
		AfxMessageBox(s1);   

		s1.Empty();   
		return;   
	}   

	CArray<CStockEntry, CStockEntry>& GetStockEntryArr() 
	{   
		CString s1 = _T("Size of Returning Array:");   
		s1.Format(_T("%s %d"), s1, stockArr.GetSize());  // This shows 0 as GetSize 
		AfxMessageBox(s1);   

		s1.Empty();   

		return this->stockArr;   
	}   
};

...

	CArray<CStockEntry, CStockEntry> stockArr;
	stockArr.Add(CStockEntry(0));
	stockArr.Add(CStockEntry(1));
	stockArr.Add(CStockEntry(2));
	stockArr.Add(CStockEntry(3));
	stockArr.Add(CStockEntry(4));
	DeptStock test;
	test.SetCStockEntryArr(stockArr);
	CArray<CStockEntry, CStockEntry> &stockArrRef = test.GetStockEntryArr();

It works fine.

What aren't you showing?

FWIW, calling Empty() on those local CStrings is unnecessary.

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: CArray problem Pin
Trupti Mehta12-Jul-08 0:57
Trupti Mehta12-Jul-08 0:57 
GeneralRe: CArray problem Pin
Mark Salsbery12-Jul-08 7:47
Mark Salsbery12-Jul-08 7:47 
QuestionHow can I display a cursor for the text? Pin
danginkgo11-Jul-08 3:35
danginkgo11-Jul-08 3:35 
AnswerRe: How can I display a cursor for the text? Pin
led mike11-Jul-08 5:22
led mike11-Jul-08 5:22 
QuestionRegarding Application.ScreenUpdating() - Draw Graph in Excel Pin
vimaltiwari11-Jul-08 3:35
vimaltiwari11-Jul-08 3:35 
AnswerRe: Regarding Application.ScreenUpdating() - Draw Graph in Excel Pin
led mike11-Jul-08 5:25
led mike11-Jul-08 5:25 
QuestionEnterCriticalSection() problem on Vista Pin
SRKSHOME11-Jul-08 3:31
SRKSHOME11-Jul-08 3:31 
AnswerRe: EnterCriticalSection() problem on Vista Pin
Mark Salsbery11-Jul-08 5:27
Mark Salsbery11-Jul-08 5:27 
GeneralRe: EnterCriticalSection() problem on Vista Pin
SRKSHOME14-Jul-08 4:58
SRKSHOME14-Jul-08 4:58 
GeneralRe: EnterCriticalSection() problem on Vista Pin
Mark Salsbery14-Jul-08 5:43
Mark Salsbery14-Jul-08 5:43 
GeneralRe: EnterCriticalSection() problem on Vista Pin
SRKSHOME14-Jul-08 19:09
SRKSHOME14-Jul-08 19:09 
GeneralRe: EnterCriticalSection() problem on Vista Pin
Mark Salsbery15-Jul-08 5:36
Mark Salsbery15-Jul-08 5:36 
GeneralRe: EnterCriticalSection() problem on Vista Pin
SRKSHOME17-Jul-08 3:12
SRKSHOME17-Jul-08 3:12 
GeneralRe: EnterCriticalSection() problem on Vista Pin
Mark Salsbery17-Jul-08 5:37
Mark Salsbery17-Jul-08 5:37 
GeneralRe: EnterCriticalSection() problem on Vista Pin
SRKSHOME12-Aug-08 1:05
SRKSHOME12-Aug-08 1:05 
AnswerRe: EnterCriticalSection() problem on Vista Pin
Joe Woodbury11-Jul-08 10:26
professionalJoe Woodbury11-Jul-08 10:26 
GeneralRe: EnterCriticalSection() problem on Vista Pin
SRKSHOME11-Jul-08 23:35
SRKSHOME11-Jul-08 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.