Solved

dynamic creation of ActiveX?

Posted on 1998-11-05
3
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

689 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