Solved

dynamic creation of ActiveX?

Posted on 1998-11-05
3
319 Views
Last Modified: 2013-11-20
What i've got is this home grown script file that reads in prog ID's and their properties. I want a container to basically take those prog ID's create my ActiveX object and set their properties dynamically on the fly. Right now I'm trying the method where I get the dispatch interface from CommandTarget in the COleClientItem::OnActivateUI() and set the properties on what I want...I was wondering if anybody has a better solution to this problem...I also have a action events for object in the scripts. The only examples I've seen for containers is that they include the ActiveX object in their program through the Component Gallery, and then It hard codes the disp IDs into the CWnd derived class, what I was thinking was I can create a CWnd derived class, and basically CreateControl() on all of my ActiveX objects and use that class to maintain my controls...Any input or code would be appreciated...Thanks...my email is rabbott@amered.com if someone wants to email me...
0
Comment
Question by:rabbott
3 Comments
 
LVL 1

Expert Comment

by:sudhirbrat
ID: 1324251
You can create ActiveX controls with CWnd::CreateControl() function, if u know the CLSID of the control. In generally all MFC ActiveX controls will implement that function.

I haven't completely understand ur problem. Can u please explain ur problem?
0
 

Author Comment

by:rabbott
ID: 1324252
OK..What I've done is derive A Class from CWnd...Basically putting everything I need in the control class to load up the ActiveX and set some properties and stuff. The problem i'm having is that I don't know how to set the UserMode of the container. I notice if I use the ActiveX Test Container and you build a generic MFC ActiveX component and insert it into that, you get the edit nodes and hatchings around your control..I want to be able to do this. Seems like mines always stuck in playmode. Their are times when I would like to be able to edit the control and times to play it back. If you can help me with that I would appreciate it...Thanks

Richard
0
 
LVL 1

Accepted Solution

by:
elf_k earned 200 total points
ID: 1324253
First of all you need to implement:

BOOL CContainerWnd::OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar)
{
    switch(dispid)
    {
    case DISPID_AMBIENT_USERMODE:
      V_VT(pvar)=VT_BOOL;
      V_BOOL(pvar)=m_UserMode;
      break;
    default:
      return CWnd::OnAmbientProperty(pSite,dispid,pvar);
    }
    return TRUE;
}

and when you need to change from user-mode to design-mode you need to do following call from IOleControl interface of all contained controls
// for all controls
//{
      CWnd* pControlWnd=...
      IUnknown* pUnknown=pControlWnd->GetControlUnknown();
      IOleControl* pOleControl;
      if(SUCCEDED(pUnknown->QueryInterface(IID_IOleControl, (void**)&pOleControl))
          pOleControl->OnAmbientPropertyChange(DISPID_USERMODE);
//}

PS: Keep in mind that not all of controls supports switching of usermode.
PPS: If you want to switch any ambient property, make it in the same manner.

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now