MapWindow / MapWinGIS

MapWinGIS.ocx is a FREE and OPEN SOURCE C++ based geographic information system programming ActiveX Control and application programmer interface (API) that can be added to a Windows Form in Visual Basic, C#, Delphi, or other languages that support ActiveX, providing your app with a map. Go to our forum for questions and help:
https://mapwindow.discourse.group/
Mozilla Public License 2.0
270 stars 134 forks source link

How do I call a Grid function with the LPDISPATCH #207

Open zcwbnu opened 3 years ago

zcwbnu commented 3 years ago

How to obtain the elevation data value according to the row and column number,After obtaining the IDISPATCH type? I don’t know why the elevation value I get is always wrong

LPDISPATCH lpDispatch = m_map.get_GetObject(layerHandle); //hr = lpDispatch->QueryInterface(IID_IDispatch, (void **)&typeinfo); UINT count; lpDispatch->GetTypeInfoCount(&count); DISPID dispid; DISPID PropertyID[5] = { 0 }; BSTR PropName[5]; PropName[0] = SysAllocString(L"Value"); PropName[1] = SysAllocString(L"row"); PropName[2] = SysAllocString(L"col");

lpDispatch->GetIDsOfNames(IID_NULL, PropName, 3, LOCALE_SYSTEM_DEFAULT, PropertyID);

VARIANTARG v[3];

v[0].lVal = 1000;
v[1].lVal = 710; v[2].pintVal= &h ; DISPPARAMS params = {v,NULL,2,0};

VARIANT vResult;

HRESULT ok = lpDispatch->Invoke(PropertyID[0], IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &params, &vResult, NULL, NULL); if (SUCCEEDED(ok)) { TRACE("%d",vResult.iVal); }