[Webinar] Streamline your web hosting managementRegister Today


ATL ActiveX - Using in HTML pages using <PARAM> Tag

Posted on 1999-11-22
Medium Priority
Last Modified: 2013-11-25
Hi Guys!
I'm getting desperate here. I'm writing an ATL component (Thanks to a few previous questions asked here...). Now it is working great, but I want to insert it into Web pages. Using HTML PARAM tag. (Using VBScripts to load the component and use functions works great, but I don't want to use it because I want a generic component that will work under netscape also!).
anyway. Using PARAM I tried two ways. One is to do this


 <PARAM NAME="Param1" VALUE="23">
 <PARAM NAME="Param2" VALUE="26">


and the other way is to use

<PARAM NAME="Line0001" VALUE="SetSomething(0,1,0)">

which didn't work either.

I was then told I need to implement PropertyBagsImpl. I did it, but that didn't work again. THEN I was told I need to override the load function of the PropertyBagsImpl template.
But this is where I'm stuck. How do I do that? the MSDN states the header to be

HRESULT Read( LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);

but if I overload it I get an error saying that this declaration differs from the original virtual function by return type or calling convention (or something like that).

What Can I do??? How do I use that LOAD thing, anyway? What are those pointers in the function? Please help...


Question by:ShadowHawk071998
LVL 32

Expert Comment

ID: 2225275
I didn't realze that Netscape Navigator supported ActiveX controls at all.
LVL 86

Expert Comment

ID: 2225399
>>I didn't realze that Netscape Navigator supported ActiveX
>>controls at all

AFAIK, it doesn't. Does it work with IE?

Author Comment

ID: 2225489
Hmmm.. Good point actually!
I tell you why I thought that VBScript won't work. It's because We need to put that ActiveX inside HTML Help documents (These are HTML documents run inside IE enviroment, I reckon). So will VBSCript work there? If so, it might work after all... :)

Anyway. I'm sure I used ActiveX Inside Netscape. They have a plug-in that enables you to run those controls (I KNOW that Microsoft Investor uses an ActiveX and I always use Netscape!)


Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Author Comment

ID: 2225504
When I said

                                    IErrorLog* pErrorLog);

I meant

  IPropertyBag* pPropBag,  //Pointer to caller's property bag
  IErrorLog* pErrorLog  //Pointer to error log

I need to override the Load and not the Read (From what I gather, the container will call the 'Load' of the control, which then will call the 'Read' to interpret the actual properties from that strange pointer he gets...
LVL 15

Accepted Solution

Tommy Hui earned 3000 total points
ID: 2225635
The correct way of handling this situation is to override the IPersistPropertyBagImpl::Load with something like this:

      CComVariant var;
      HRESULT hr;
      var.vt = VT_I4;
      hr = pPropBag->Read(L"noItems", &var, pErrorLog);
      if (FAILED(hr))
            return hr;
      if (var.vt != VT_I4)
            return E_INVALIDARG;

      long items = var.iVal;

      OLECHAR strParam[8];
      for (long idx = 1; idx <= items; idx++)
            swprintf(strParam, L"Item%d", idx);
            hr = pPropBag->Read(strParam, &var, pErrorLog);
            if (FAILED(hr))
                  return hr;
            if (var.vt == VT_BSTR)
      return IPersistPropertyBagImpl<CURLTreeView>::Load(pPropBag, pErrorLog);

Note that this was written because IPersistPropertyBagImpl does not know how to deal with arrays, so you will have to write a custom version.

But, even if you do this, if IE is set up with a high security, the control will not see the parameters. You will need to add additional code to get around this security problem. You will need to support IObjectSafety.

To do this, add to your derivation

  public IObjectSafetyImpl<YourClass>,

Add to the COM map


Add the method you want to override:

// IObjectSafety
   STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwSupportedOptions, DWORD dwEnabledOptions);

Add this code to your .cpp module

STDMETHODIMP YourClass::SetInterfaceSafetyOptions(REFIID riid, DWORD dwSupportedOptions, DWORD dwEnabledOptions)
   if (riid == IID_IPersistPropertyBag)
      if (dwEnabledOptions != INTERFACESAFE_FOR_UNTRUSTED_DATA)
         return E_FAIL;
      return S_OK;
   return IObjectSafetyImpl<CURLTreeView>::SetInterfaceSafetyOptions(riid, dwSupportedOptions, dwEnabledOptions);

That should make it work now.

Author Comment

ID: 2235754
This actually worked, although It took me several hours.
The part

hr = pPropBag->Read(L"noItems", &var, pErrorLog);

Didn't work... but I can live without it. I know the parameters.

Just one question, though. At the end you say

IObjectSafetyImpl<CURLTreeView>::SetInterfaceSafetyOptions(riid, dwSupportedOptions, dwEnabledOptions);

Which didn't work for me. Can you please explain and say why I need it? (It works great without it!).

Thanks again!!!

LVL 15

Expert Comment

by:Tommy Hui
ID: 2236605
Oops. Sorry, but CURLTreeView is my base class from which this code was taken. You don't need to call the base class unless you are deriving from a class that has implements IObjectSafetyImpl.

Author Comment

ID: 2236754
Oh. Okay. Gotcha.
To finalise things, I guess that


Is also one of your data members (Some sort of vector thing).



Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

612 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