Calling ActiveX Methods from MMC Snap-in  
Author Message
Chris55





PostPosted: Visual C++ General, Calling ActiveX Methods from MMC Snap-in Top

Hi ...

I have a ActiveX Control and I'm using it in a MMC Snap-in. This is my first time. I have some sample code that shows how to access the properties from the snap-in. I have shown this code below.

switch (event)
{

case MMCN_INITOCX:
{
// Use ATLs IDispatch helper class to access ActiveX Properties
CComDispatchDriver spStatus = LPUNKNOWN(param);

// Set the TestValue value in ActiveX Control
spStatus.PutPropertyByName(L"TestValue", &CComVariant(7));
}
break;
}


So ... I have a method in the ActiveX Control and would like to execute it ... For example the About box or the PropertySheet or in my case a simple method called Beep() that will make a sound.

Thanks,
Chris






Visual C++13  
 
 
Chris55





PostPosted: Visual C++ General, Calling ActiveX Methods from MMC Snap-in Top

Hi ...

Here is an idea ... this does not seem to work.


case MMCN_INITOCX:

{
// Use ATLs IDispatch helper class
CComDispatchDriver spStatus = LPUNKNOWN(param);

// Set the TestValue value
//spStatus.PutPropertyByName(L"TestValue", &CComVariant(7));

HRESULT hresult;
IDispatch FAR* pdisp = (IDispatch FAR*)NULL;
DISPID dispid;
OLECHAR FAR* szMember = L"BeepSound2";

hresult = spStatus.p->GetIDsOfNames(IID_NULL,
&szMember,
1,
LOCALE_SYSTEM_DEFAULT,
&dispid);

spStatus.p->Invoke(dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
NULL,
NULL,
NULL,
NULL);

}
break;