Solved

Using a ActiveX Control in a DLL

Posted on 2002-06-18
5
462 Views
Last Modified: 2008-01-09
I am new for VC++. I am currently writing a DLL which will in turn invoke the function of ActiveX control.

I create a MFC AppWizard (dll) project and add the reference of the activeX Control. It compiled OK.
I write a simple console program to test it. I seem OK to load the dll. However, when I try to invoke the function of the ActiveX Control. I got error.


void CWnd::GetProperty(DISPID dwDispID, VARTYPE vtProp,
     void* pvProp) const
{
     ASSERT(m_pCtrlSite != NULL);    // not an OLE control (not yet, at least)
....
}

It got error on the first ASSERT statement of the winocc.cpp file. I don't know what is going on. I do call the AfxEnableControlContainer(); already.

Do I miss anything?

0
Comment
Question by:nixonc
5 Comments
 
LVL 22

Expert Comment

by:ambience
ID: 7087522
possibly a lot, how are you instantiating the control?
0
 
LVL 3

Expert Comment

by:jimbucci
ID: 7087524
An ActiveX control requires a window to draw itself - the client site.  Is your dll itself an ActiveX control?
Are you actually trying to display the wrapped control using your dll?  
The MFC ActiveX control wizard can create a container control which allows you to wrap a control into your control.  It is a pain to implement though.
I suggest creating an ATL composite control and pulling the ActiveX control into it.
I can provide code suggestions since I've done this and it works great.  There are a few caveats so the response would be lengthy.  Let me know if this would help you.
Jim
 
0
 

Author Comment

by:nixonc
ID: 7097862
I just declare the control inside the application object which inherite from CWinApp. My dll itself is not an ActiveX control. I not trying to display any thing. Is there a different windowed control and windowless control.

Here are the story. We are developing an application which try to control different brand of digital camera. We try to standardize the interface between the application and the digital camera. SDK from Nikon have been wrapped into a dll easily since it provide all the source code. However, the SDK from Olympus is an ActiveX control.  So I have to wrapped the ActiveX Control into DLL as well.

All I need is a DLL which can invoke the ActiveX function.
What kind of project should I create? Any suggestion?
Can ATL composite control can do?
0
 
LVL 3

Accepted Solution

by:
jimbucci earned 100 total points
ID: 7098275
If you're getting a m_pCtrlSite error that means that the ActiveX control is looking for window in which to display itself.  Even if it doesn't display anything it still wants a window.  So you need to trick the ActiveX control into thinking it has a window.  I can suggest one thing to try - create the control on the fly.  Try this:

IOlympusPtr  m_spControl;// smart pointer to control

// Create an ActiveX control instance and place it into this window
   m_spOlympus.CreateInstance(__uuidof(TChart));
   if( m_spChart )
   {
      CComPtr<IAxWinHostWindow> spHost;
      QueryHost(&spHost);
      spHost->AttachControl(m_spControl, m_hWnd);
   }
   This creates a control and gives it a client site.  However you don't have a window.  
I haven't tried this, but create a window handle but don't show it.
   HWND m_Hwnd = CreateWindow(...)
I don't know if this will work - I can try a few things and get back to you.
Good luck.
JB
0
 
LVL 11

Expert Comment

by:griessh
ID: 7262371
Dear nixonc

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jimbucci"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 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

24 Experts available now in Live!

Get 1:1 Help Now