[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 1999-11-22
8
Medium Priority
?
881 Views
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

--

<OBJECT ID="MYCONTROL" WIDTH=470 HEIGHT=62
 CLASSID="CLSID:MYCONTROLCLSID">
 <PARAM NAME="Param1" VALUE="23">
 <PARAM NAME="Param2" VALUE="26">
 </OBJECT>

--

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...

Thanks!

Ron.
0
Comment
Question by:ShadowHawk071998
8 Comments
 
LVL 32

Expert Comment

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

Expert Comment

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

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

Author Comment

by:ShadowHawk071998
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!)

Cheers,

Ron.
0
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

by:ShadowHawk071998
ID: 2225504
BTW!!!
OOPS!!!
When I said

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


I meant

HRESULT Load(
  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...
 
0
 
LVL 15

Accepted Solution

by:
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:

STDMETHODIMP YourClass::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
{
      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;
      var.Clear();

      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)
                  m_URLs.push_back(CComBSTR(var.bstrVal));
            var.Clear();
      }
      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

  COM_INTERFACE_ENTRY(IObjectSafety)

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.
0
 

Author Comment

by:ShadowHawk071998
ID: 2235754
Hi!
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!!!

Ron.
0
 
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.
0
 

Author Comment

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

  m_URLs

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

THanks,

Ron.
0

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