ActiveX (ATL) question?
-
I created an ATL project and inserted into it a Composite Control Object. It works fine , but need to read some info from the browser specified in the OBJECT tag ... ... How I read the MyValue from my ATL Composite Control? Thankx:eek: xxx
I figure you would have better luck in the COM section. You wanna use the tag. I dunno if i'm right with the following(i'm tired haven't slept yet) but I think what you want is custom properties in COM there is no such thing as just assigning values to your object data members, you MUST use get/set mutators and accessors. Your gonna need something similar to this:
STDMETHODIMP IMyInterface::get_MyAttrib(BSTR* pVal)
{
m_MyMember = *pVal;
return S_OK;
}//Also you need some way to tie the attribute to your variable
//This is accomplished through IDL, I don't have a reference handy so don't ask...This might be entirely wrong, but will give you some starting ground p.s-If your building a control for web sites only...have you considered using IE lite...? less overhead and better suited for webpages.:) "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
I created an ATL project and inserted into it a Composite Control Object. It works fine , but need to read some info from the browser specified in the OBJECT tag ... ... How I read the MyValue from my ATL Composite Control? Thankx:eek: xxx
Besides creating the get and set member functions for the member variable, you will need to derive your class from IPersist.
-
Besides creating the get and set member functions for the member variable, you will need to derive your class from IPersist.
You are not bothering me, I like to help. Anyways, here are some segments of code from a control that I wrote. First declare the property get_ and put_ functions in idl.
[ object, uuid(...), dual, helpstring("IHTMLInfoCtl Interface"), pointer_default(unique) ] interface IHTMLInfoCtl : IDispatch { **[propput, id(0)] HRESULT URL([in]BSTR pVal); [propget, id(0)] HRESULT URL([out,retval]BSTR* newVal);** };
Next implement these functions in your class interface. The key to tying the data together is deriving your ATL object from the IPersistStream interface, then providing one of the IPersist implementations. I used IPersistePropertyBagImpl and it works fine. I am not sure, but I think that One of the IPersistxxx classes that I have declared may not need to be declared, but this code works for me.class ATL_NO_VTABLE CHTMLInfoCtl : public CComObjectRootEx, public CComCoClass, ... **public IPersistStreamInitImpl, public IPersistStorageImpl,** ... **public IPersistPropertyBagImpl,** ... { public: CHTMLInfoCtl(); ~CHTMLInfoCtl(); ...
One final thing, add the IPersist entries to your COM map here.BEGIN_COM_MAP(CHTMLInfoCtl) COM_INTERFACE_ENTRY(IHTMLInfoCtl) ... **COM_INTERFACE_ENTRY(IPersistStorage) COM_INTERFACE_ENTRY(IPersistStreamInit) COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit) COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistPropertyBag) COM_INTERFACE_ENTRY(IPersistPropertyBag)** END_COM_MAP() **BEGIN_PROP_MAP(CHTMLInfoCtl) PROP_ENTRY("URL", 0, CLSID_NULL) END_PROP_MAP()** // IHTMLInfoCtl public: STDMETHOD(get_URL)(BSTR *pVal); STDMETHOD(put_URL)(BSTR newURL); private: CComBSTR m_bstrURL; };
let me know if you have other questions.