?
Solved

dynamic creation of ActiveX?

Posted on 1998-11-05
3
Medium Priority
?
340 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Suggested Courses

743 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