Click here to Skip to main content
15,911,139 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: __asm and C++ inheritance Pin
jk6112-Mar-04 9:49
jk6112-Mar-04 9:49 
GeneralLINK : fatal error LNK1209 Pin
melwyn12-Mar-04 4:58
melwyn12-Mar-04 4:58 
GeneralRe: LINK : fatal error LNK1209 Pin
David Crow12-Mar-04 5:10
David Crow12-Mar-04 5:10 
GeneralRe: LINK : fatal error LNK1209 Pin
melwyn12-Mar-04 5:43
melwyn12-Mar-04 5:43 
GeneralRe: LINK : fatal error LNK1209 Pin
Steve S12-Mar-04 5:48
Steve S12-Mar-04 5:48 
GeneralRe: LINK : fatal error LNK1209 Pin
melwyn12-Mar-04 5:54
melwyn12-Mar-04 5:54 
GeneralTooltips for ToolBar. Pin
bin892212-Mar-04 4:45
bin892212-Mar-04 4:45 
GeneralSAFEARRAY Question Pin
Nick Parker12-Mar-04 4:40
protectorNick Parker12-Mar-04 4:40 
I might be misunderstanding the workings of a VARIANT, but I am trying to pack a SAFEARRAY and assign it to my VARIANT. When I place a break point I can see I am getting data into the array but when I try to debug the component in VB I can only get 1 element back which is 0. Does anyone see something wrong with this, this is the first time I have tried using a SAFEARRAY so bare with me. Thanks in advance.

STDMETHODIMP CMoses::GetNumbers(VARIANT *pVal)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	HRESULT h;
	long lDimension[2];
	int startyear, runyear;
	startyear = 3;
	runyear = 68;
	typedef vector<double> collection;
	collection numbers;

	// Get data from the MoSes object 
	// and place in vector.
	for(int i = startyear * 12; i < runyear * 12; i += 12)
	{
		IColumn col(root.Column("nsv_e_0"));
		if(col != NULL)
		{
			CString num;
			num.Format("%d", i);
			numbers.push_back(col.value(num));
		}
	}

	// SAFEARRAY stuff.
	SAFEARRAYBOUND bounds[1];
	SAFEARRAY *psa = NULL;
	
	// Initialize bounds.
	bounds[0].lLbound = 1;
	bounds[0].cElements = numbers.size();

	// Create SAFEARRAY.
	psa = SafeArrayCreate(VT_R8, 1, bounds);

	if (psa == NULL) throw ERROR_NOT_ENOUGH_MEMORY;

	
	int j = 0;

	vector<double>::iterator it;

	//Move data from vector to SAFEARRAY
	for(it = numbers.begin(); it != numbers.end(); it++, j++)
	{
		lDimension[1] = j;
		lDimension[0] = 0;
		h = ::SafeArrayPutElement(psa, lDimension, &it);
	}

	pVal->parray = psa;

	return S_OK;
}


- Nick Parker
  My Blog

GeneralRe: SAFEARRAY Question Pin
Steve S12-Mar-04 5:50
Steve S12-Mar-04 5:50 
GeneralProblem Solved Pin
Nick Parker12-Mar-04 8:19
protectorNick Parker12-Mar-04 8:19 
QuestionHow to read a cookie in C++ Pin
Anonymous12-Mar-04 4:39
Anonymous12-Mar-04 4:39 
AnswerRe: How to read a cookie in C++ Pin
David Crow12-Mar-04 5:07
David Crow12-Mar-04 5:07 
GeneralRe: How to read a cookie in C++ Pin
black97610-May-04 3:50
black97610-May-04 3:50 
GeneralRe: How to read a cookie in C++ Pin
David Crow10-May-04 3:59
David Crow10-May-04 3:59 
Questiondid u use video memory before? Pin
includeh1012-Mar-04 3:55
includeh1012-Mar-04 3:55 
AnswerRe: did u use video memory before? Pin
antlers12-Mar-04 5:49
antlers12-Mar-04 5:49 
GeneralRe: did u use video memory before? Pin
includeh1012-Mar-04 16:13
includeh1012-Mar-04 16:13 
Generaldebug problem Pin
star fish12-Mar-04 3:13
star fish12-Mar-04 3:13 
GeneralRe: debug problem Pin
Tim Smith12-Mar-04 4:03
Tim Smith12-Mar-04 4:03 
GeneralRe: debug problem Pin
star fish12-Mar-04 4:25
star fish12-Mar-04 4:25 
GeneralTitle bar.. Pin
Dennis L12-Mar-04 3:12
Dennis L12-Mar-04 3:12 
GeneralRe: Title bar.. Pin
Prakash Nadar12-Mar-04 3:29
Prakash Nadar12-Mar-04 3:29 
GeneralRe: Title bar.. Pin
Gary Wheeler12-Mar-04 4:24
Gary Wheeler12-Mar-04 4:24 
QuestionHow to insert a picture inmy dialog box Pin
Deepak Samuel12-Mar-04 2:18
Deepak Samuel12-Mar-04 2:18 
AnswerRe: How to insert a picture inmy dialog box Pin
David Crow12-Mar-04 2:23
David Crow12-Mar-04 2:23 

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.