오후 1:46 2000-05-29
조경민 이차원 배열이 담아 있는 varData로 배열 요소 얻어오기
html vbscript -> ATL VC
-----------------------------------------------------------------'
STDMETHODIMP CChartGen::fnRdsChart(VARIANT varData)
{
// TODO: Add your implementation code here
SAFEARRAY* psaData;
psaData = CSafeArray<int>::fnGetSafeArray( varData );
SAFEARRAYBOUND saDim[2];
SafeArrayGetLBound( psaData, 1, (long*)&saDim[0].lLbound );
SafeArrayGetUBound( psaData, 1, (long*)&saDim[0].cElements );
saDim[0].cElements-=saDim[0].lLbound;
SafeArrayGetLBound( psaData, 2, (long*)&saDim[1].lLbound );
SafeArrayGetUBound( psaData, 2, (long*)&saDim[1].cElements );
saDim[1].cElements-=saDim[1].lLbound;
HRESULT hres;
VARIANT varValue;
long arrDim[2];
int xMin = saDim[0].lLbound;
int xMax = xMin + (int)saDim[0].cElements - 1;
int yMin = saDim[1].lLbound;
int yMax = yMin + (int)saDim[1].cElements - 1;
char szBuf[100];
sprintf( szBuf, "[%d,%d] [%d,%d]", xMin, xMax, yMin, yMax );
MessageBox( NULL, szBuf, "Safe2Dim GetValue", MB_OK );
int x,y;
for (x = xMin; x <= xMax; x++) {
arrDim[0] = x;
for (y = yMin; y <= yMax; y++) {
arrDim[1] = y;
if (hres = SafeArrayGetElement(psaData, arrDim, &varValue)) throw hres;
if( varValue.vt & VT_BSTR)
{
USES_CONVERSION;
char* pszValue = W2A(varValue.bstrVal);
char szBuf[100];
sprintf( szBuf, "[%d,%d] %s", x, y, pszValue );
MessageBox( NULL, szBuf, "Safe2Dim GetValue BSTR", MB_OK );
}
else if( varValue.vt & VT_R8 )
{
double dblValue = varValue.dblVal;
char szBuf[100];
sprintf( szBuf, "[%d,%d] %lf", x, y, dblValue );
MessageBox( NULL, szBuf, "Safe2Dim GetValue VT_R8", MB_OK );
}
else
{
MessageBox( NULL, "어라..","Safe2Dim GetValue VT_?", MB_OK);
}
}
}
조경민 이차원 배열이 담아 있는 varData로 배열 요소 얻어오기
html vbscript -> ATL VC
-----------------------------------------------------------------'
STDMETHODIMP CChartGen::fnRdsChart(VARIANT varData)
{
// TODO: Add your implementation code here
SAFEARRAY* psaData;
psaData = CSafeArray<int>::fnGetSafeArray( varData );
SAFEARRAYBOUND saDim[2];
SafeArrayGetLBound( psaData, 1, (long*)&saDim[0].lLbound );
SafeArrayGetUBound( psaData, 1, (long*)&saDim[0].cElements );
saDim[0].cElements-=saDim[0].lLbound;
SafeArrayGetLBound( psaData, 2, (long*)&saDim[1].lLbound );
SafeArrayGetUBound( psaData, 2, (long*)&saDim[1].cElements );
saDim[1].cElements-=saDim[1].lLbound;
HRESULT hres;
VARIANT varValue;
long arrDim[2];
int xMin = saDim[0].lLbound;
int xMax = xMin + (int)saDim[0].cElements - 1;
int yMin = saDim[1].lLbound;
int yMax = yMin + (int)saDim[1].cElements - 1;
char szBuf[100];
sprintf( szBuf, "[%d,%d] [%d,%d]", xMin, xMax, yMin, yMax );
MessageBox( NULL, szBuf, "Safe2Dim GetValue", MB_OK );
int x,y;
for (x = xMin; x <= xMax; x++) {
arrDim[0] = x;
for (y = yMin; y <= yMax; y++) {
arrDim[1] = y;
if (hres = SafeArrayGetElement(psaData, arrDim, &varValue)) throw hres;
if( varValue.vt & VT_BSTR)
{
USES_CONVERSION;
char* pszValue = W2A(varValue.bstrVal);
char szBuf[100];
sprintf( szBuf, "[%d,%d] %s", x, y, pszValue );
MessageBox( NULL, szBuf, "Safe2Dim GetValue BSTR", MB_OK );
}
else if( varValue.vt & VT_R8 )
{
double dblValue = varValue.dblVal;
char szBuf[100];
sprintf( szBuf, "[%d,%d] %lf", x, y, dblValue );
MessageBox( NULL, szBuf, "Safe2Dim GetValue VT_R8", MB_OK );
}
else
{
MessageBox( NULL, "어라..","Safe2Dim GetValue VT_?", MB_OK);
}
}
}
'KB > MFC/Win32' 카테고리의 다른 글
[com] ASP 서포트 하기 (0) | 2004.03.19 |
---|---|
ATL Timer 쓰기 (0) | 2004.03.19 |
[com] 웹 페이지(ASP/Script)에서 넘어오는 문자열 잡아 내기 (0) | 2004.03.19 |
[com] 배열 값 넣기 구현 (0) | 2004.03.19 |
_bstr_t 메모리릭 (0) | 2004.03.19 |