M
MFK schrieb:
masanne schrieb:
wie kommst du darauf, dass ich zwei Instanzen erzeuge? wegen cocreateinstance und createcontrol?
Genau. Ich vermute, letzteres erzeugt auch eine Instanz des Steuerelements. Und vermutlich kann nur die richig auf CONFIG reagieren.
Das war der entscheidende Satz. Danke Schön.
...
CoInitialize(NULL);
CWnd m_ControlWrapper;
RECT rct = {0,0,5,50};
BOOL bStat=FALSE;
bStat= m_ControlWrapper.CreateControl(clsid, "Spectrometer", WS_CHILD, rct, this, 1212, NULL, FALSE, NULL);
if (bStat == FALSE)
{
MessageBox ("Could not place control");
return;
}
// Use the IUnknown of the control.
LPUNKNOWN pUnk = m_ControlWrapper.GetControlUnknown();
// From there get the IDispatch interface of control.
LPDISPATCH pInterface = NULL;
pUnk->QueryInterface(IID_IDispatch, (LPVOID*)&pInterface);
CString CstrMethod = "CONFIG"; // andere Methode z.B. "SCAN"
BSTR BstrMethod = CstrMethod.AllocSysString();
DISPID dispid;
// get the id of the method
HRESULT hRet = pInterface->GetIDsOfNames(IID_NULL, &BstrMethod, CLSCTX_INPROC_SERVER , LOCALE_SYSTEM_DEFAULT, &dispid);
m_ControlWrapper.InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);//InvokeHelper(0xc, DISPATCH_METHOD , VT_EMPTY, NULL, NULL);
CoUninitialize();
...
Nur, dass ich das CONFIG-Window nicht angezeigt bekomm. Aber wenn ich es mit einer anderen Methode versuche, klappt es.