CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Saint Paul, Minnesota, US
    Posts
    91

    Accessing ActiveX Methods from MMC Snap-in

    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.

    Code:
        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

  2. #2
    Join Date
    May 1999
    Location
    Saint Paul, Minnesota, US
    Posts
    91

    Re: Accessing ActiveX Methods from MMC Snap-in

    He again ...

    I have tryed this and it does not seem to all the method ???
    I will try to look further.


    Code:
                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);

    Thanks,
    Chris

  3. #3
    Join Date
    Jan 2003
    Location
    Cambridge, UK
    Posts
    752

    Re: Accessing ActiveX Methods from MMC Snap-in

    here you can find some useful samples of how to invoke COM object methods dynamically
    Cheers,

    Alex
    Please rate this post if you find it helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured