|
Ah. No I guess not. I think I've mixed some concepts up. I need to redo all this some day.
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
Has anyone used this successfully? I need to do something so simple it's pathetic, but I haven't figured out HOW... Here's what I want to do:
I'd like to have a webpage that loads my dll (it's in a cab and all that)... And it's being called like this:
<object classid="clsid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" codebase="XXXXXX.CAB">
<param name="text" value="Yo man!">
</object>
So here's the deal... All I want said application to do... Is to be able to get that text in the param tag!!! Any hints/code snippets in the right direction? I've been having a bugger of a time, and Microsoft's help pages are of NO help for a newb like me!
I know it's probably something easy, but I can't get it to work! Thanks in advance!
|
|
|
|
|
The problem is that the simple stuff doesn't work with BSTRs
In DevStudio6, If my ATL control had the interface ITestControl & the class name CTestControl , I would do the following...
* Inherit from IPersistPropertyBagImpl
* add COM_INTERFACE_ENTRY(IPersistPropertyBag) to BEGIN_COM_MAP(CTestControl)
* Add a member variable that will store the "Yo man!", maybe CComBSTR m_bsText;
* In workspace view, right click on ITestControl, and select "Add Property"
- Set the property type to BSTR,
- the name to "test",
- uncheck "Get Function"
- leave "Put Function" enabled
- Remember the "id(n)" number displayed in the implementation preview at the bottom of the dialog, you'll need that. It's the dispatch ID
* In your header file, look for BEGIN_PROP_MAP(CTestControl)
- Add the entry PROP_DATA_ENTRY("test",1,CLSID_NULL) . Observe that the number (in this case 1) is THE SAME dispatch ID for the property you just added!
* Modify the newly created "CTestControl::put_test(BSTR newVal) " to assign newVal to the local variable m_bsText .
Now when your control loads, IPersistPropertyBagImpl will call CTestControl::put_test(BSTR newVal) and store the value "Yo man!" in m_bsText
|
|
|
|
|
Wow, thanks SO much. That totally answers my question. I'll give it a try and see what happens. Thanks again, Jason!
|
|
|
|
|
Well, I gave that a try... The only thing is this...
I had to add these two parts in:
(110) BEGIN_COM_MAP(CIEBand)
(111) COM_INTERFACE_ENTRY(IPersistPropertyBag)
(112) END_COM_MAP()
(113)
(114) BEGIN_PROP_MAP(CIEBand)
(115) PROP_DATA_ENTRY("text",1,CLSID_NULL)
(116) END_PROP_MAP()
I didn't have the com or prop maps in there before...
When I went to compile, it crapped out on the PROP_DATA_ENTRY line, with the following error(s):
IEBand.h(115) : error C2059: syntax error : 'constant'
IEBand.h(115) : error C2059: syntax error : ','
IEBand.h(116) : error C2143: syntax error : missing ';' before '{'
IEBand.h(116) : error C2447: '{' : missing function header (old-style formal list?)
IEBand.h(116) : error C2059: syntax error : '}'
IEBand.h(116) : error C2059: syntax error : 'return'
IEBand.h(116) : error C2059: syntax error : '}'
YOUCH! :P Any thoughts on this?
|
|
|
|
|
Whoops!
PROP_ENTRY("test", 1, CLSID_NULL)
Did I mention that individual milage may vary?
|
|
|
|
|
Heheheh. Yeah, figured that out JUST a second ago. :P Thanks a ton, buddy.
|
|
|
|
|
Hi
I’ve got an ATL control (ActiveX) which currently exposes a property page that is used to manipulate all the properties in the control (This property page is launched in the usual manner by the user activating the ‘Custom Properties’ item in the container).
However, instead of displaying a property page to manipulate my control, I need to execute an arbitrary piece of code that displays a custom built editor dialog. My problem is that I cannot find out how to execute an arbitrary piece of code in response to the user clicking the “(custom)”
button on the control container’s property pane (or a similarly easy method of the user activating the editor).
One approach that I have considered is to create and show the dialog from the property page’s InitDialog handler, then destroy the property sheet after the custom dialog has exited (The problem here is knowing how to close the entire property sheet and not just the page) - I'm sure there must be other approaches to this problem though.
Thanks
|
|
|
|
|
I want to call a atl component from vbscript dynamically how can i do it please explain it briefly or give me some articles links
ThanX in advance
Inam
|
|
|
|
|
Your ATL component must expose a dispinterface or dual interface.
--
C'est normal!
|
|
|
|
|
How do you Sign an ActiveX Control?
Where Can i get the Certificate required?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
The first thing you'll need is an Authenticode Code Signing Certificate. I bought mine from Thawte - I think it runs 160 USD for two years.
You'll have to jump through some hoops. You need to supply the cert vendor with your business and web domain info to verify your identity.
|
|
|
|
|
|
I have an ATL ActiveX DLL control & in Internet Explorer, on an XP system with themes enabled - any dialogs that my control displays do not have any themes active!
I've themed my EXE projects before with no issues. (manifest resource type=24 id=1, InitCommonControls, comctl32.lib, ect..).
But for some reason when I apply the same modifications to my DLL - it doesn't work.
The dialogs that I display from the control have a themed non-client area (the caption & 'x' close button), but the dialog client controls are not themed.
I attempted to use the theme library (uxtheme.dll) to force the themeing of the dialog & its child controls, but that failed horribly (probably from a lack of understanding the theme lib), the best(???) I was able to accomplish is the removing of the theme from the non-client area.
Does any one know why my control's dialog doesn't show up as being themed in IE??
Thanks
|
|
|
|
|
|
I think I'm missing something else. I tried resource id's 1-16 for my manifest file & it still didn't work
So as a sanity check I created to following quick ActiveX project in DevStudio6SP5
* File>New>Projects>ATL COM AppWizard
* DLL Project, nothing checked, finish
* Insert>New ATL Object,Category "Controls", Full Control
* ATL Object Wizard Properties > ShortName = TestBob, left everything else as default
* Add a WM_LBUTTONDBLCLK handler that displays a simple MessageBox
OR if you're lazy & don't want to double click all the time...
* Add a Button control to the window in your WM_CREATE handler (be sure to enable m_bWindowOnly)
* Added a manifest resource, type 24, id=2
* Added ComCtl32.lib to the linker
* In the constructor, added AtlInitCommonControls(ICC_WIN95_CLASSES|ICC_DATE_CLASSES|ICC_USEREX_CLASSES|ICC_COOL_CLASSES|ICC_INTERNET_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_NATIVEFNTCTL_CLASS); Wanted to make sure I wasn't missing anything
Unfortunatly the buttons are still not themed.
I even added 511 manifests to the project, numbered 1-512. Sort of a buckshot approch. Still no luck.
Is there some obsure interface I need to implement?
FYI: CPLs (Control Panel Applets) should have a manifest resource of 123
|
|
|
|
|
|
Wow, thanks Michael - that did the trick!
I removed my ComCtl32.lib linker entry & the call to InitCommonControls & it still worked!
So for future users that are having similar issues, All I needed for my ActiveX control was..
* A valid manifest resource type=24 with an ID=2
* #define ISOLATION_AWARE_ENABLED 1 in stdafx.h before all other #includes
(I think that this is the article[^] you ment)
Now I just want to know what the heck all this isolation stuff is & why it added 4k to the size of my DLL I'll google for it later.
|
|
|
|
|
(This is the correct version, with < >) )
Hi,
Consider the following template
template<typename T>
class X
{
//...
};
Now, I would like to put pointers to the different instantiations of the above template for ex
X<int>* xi;
X<double> *xd;
in a single stl container, let's say a vector. Can I do it in an elegant way ?
(Well, actually I can, using a vector<void*>. But after that how do I get back my objects ?)
Thank you,
Andras
|
|
|
|
|
This can be handled in a number of ways that depend on what you want to do with these objects later. Probably the most obvious solution is to write an abstract class from which all X instantiations derive from, and use this as the type of the pointers stored in te container:
class X_base
{
virtual foo()=0;
...
}
template <class T>
class X: public X_base
{
...
};
vector<X_base*> X_vector; Is this suitable for you?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, making an abstract base class solves my problem.
But I'm curiuos what other solutions might exist.
Andras
|
|
|
|
|
Hello Joo,
I think Joaquin's solution is really cool. But I think we may have missed your earlier concern : how to obtain the actual derived class object contained within the vector.
If we used a vector of pointers to X_base objects, we will obtain only pointers to X_base objects when we iterate through the vector.
We need to be able to determine at runtime the following information :
1. What is the X_base-derived-template-class of each vector item.
2. What is the type that is actually used to instantiate the X_base-derived template class (in your earlier example, this is actually 'int' or 'double').
Inspired by Joaquin, I went on to refine his example source codes and produced the following :
#include <vector>
#include <iostream>
#include <typeinfo.h>
using namespace std;
class X_base
{
public :
X_base()
{
}
virtual operator const type_info&() = 0;
};
template <class T>
class X: public X_base
{
public :
typedef T MyType;
X(MyType t) :
m_t(t),
m_ti(typeid(t))
{
}
virtual operator const type_info&()
{
return m_ti;
}
MyType& GetValue()
{
return m_t;
}
protected :
MyType m_t;
const type_info& m_ti;
};
typedef X<int> X_int;
typedef X<double> X_double;
typedef std::vector<X_base*> X_base_vector;
int _tmain(int argc, _TCHAR* argv[])
{
X_int* pxi = new X_int(5);
X_double* pxd = new X_double(0.85);
X_base_vector x_base_vector;
X_base_vector::iterator theIterator;
const type_info& ti_int = typeid(int);
const type_info& ti_double = typeid(double);
int i = 0;
cout << ti_int.name() << endl;
cout << ti_double.name() << endl;
x_base_vector.push_back(pxi);
x_base_vector.push_back(pxd);
for (theIterator = x_base_vector.begin(); theIterator != x_base_vector.end(); theIterator++)
{
X_base* px = *theIterator;
if (ti_int == (const type_info&)(*px))
{
X_int* pxi = dynamic_cast<X_int*>(px);
cout << "px == X<int>" << endl;
cout << "Value : " << pxi -> GetValue() << endl;
}
if (ti_double == (const type_info&)(*px))
{
X_double* pxd = dynamic_cast<X_double*>(px);
cout << "px == X<double>" << endl;
cout << "Value : " << pxd -> GetValue() << endl;
}
cout << ((const type_info&)(*px)).name() << endl;
}
return 0;
}
Essentially, I used Run-Time-Type-Information (RTTI) to help determine the class (X_base-derived) of each vector item as well as to determine the type that is actually used to instantiate the X_base-derived template class.
Hope the above code will be helpful to you and Joaquin.
Thanks,
Bio.
|
|
|
|
|
You could also use the boost::any as container item type. Please see http://www.boost.org/doc/html/any.html[^] for more information.
If you think this is something you would like to use, then you do not need to download the entire boost source code. You can download any.hpp and use it. No link libraries required.
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
Hi,
Consider the following template
template<typename t="">
class X
{
//...
};
Now, I would like to put pointers to the different instantiations of the above template for ex
X<int>* xi;
X<double> *xd;
in a single stl container, let's say a vector. Can I do it in an elegant way ?
(Well, actually I can, using a vector<void*>. But after that how do I get back my objects ?)
Thank you,
Andras
|
|
|
|
|
Hello everyone
How to load a MFC dll to a WTL project? If having some sample, could you send me by email?
Thank you .
-Freehawk
|
|
|
|