|
Stober wrote: Do I have to resort to sending normal win32 api messages to populate the combo box list?
Yes, if you stick with plain ATL. You can also use WTL, which has the control wrappers that you're looking for.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
is it fine to contain other objects as data members of outer object in ATL. or we need to implement containment to do this.
Z.A
|
|
|
|
|
I am having problems with ATL and RichEdit controls.
I created an ActiveX (composite control using ATL that just contains a
RichEdit box (that was added with the Resource Editor). When the control is
displayed in IE5, the "backspace" key does not work properly in the RichEdit
box. Instead of deleting the chars in the box, pressing the "backspace" key
while in the RichEdit box causes the browser to go "Back" to the previous
URL. (Strange!)
|
|
|
|
|
I'm trying to figure out how exactly vector::push_back() creates objects.
Looks like vector::push_back() will create a lot of copies by copy constructor and destruct a lot. In other words, if I need to put a counter in the copy constructor to monitor how many copy of the objects are created during the run, I will get a number which I don't exactly understand why. Can anybody explain why push_back() keep making copies and deleting copies?
By running the following sample program, I supose to get 2,4,6,8,10 as output, but I get 21,22,23,24,25. Why is that?
Thanks!
class CVecTest
{
public:
CVecTest() {m_intCount = ++m_classNumber;}
CVecTest::CVecTest(const CVecTest &vec) {m_intCount = ++m_classNumber;}
~CVecTest(){};
static int m_classNumber;
int m_intCount;
};
int CVecTest::m_classNumber = 0;
int main(int argc, char* argv[])
{
vector<cvectest> vec;
for (int i=0; i<5; i++)
{
CVecTest p;
vec.push_back(p);
}
for (int i=0; i<5; i++)
cout << vec[i].m_intCount << endl;
return 0;
}
|
|
|
|
|
All STL containers have value semantics and as such copy or assign elements.
Steve
|
|
|
|
|
Stephen Hewitt wrote: All STL containers have value semantics
For the next version of C++ standard it is planned to add move semantics[^]. That would be
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
In the mean time you can get these semantics by butting smart pointers in the container - Boost has many such pointers.
Steve
|
|
|
|
|
std::vector and its friends in the C++ standard library will copy an added element and store the copy, not the original. std::vector doesn't destroy a contained object - it's the object destructor that handles destruction when the std::vector goes out of scope.
There's no container in the C++ standard library, which can share pointers that will be deleted when the last reference to them die. There are such alternatives in Boost[^] and Loki[^].
--
The Blog: Bits and Pieces
|
|
|
|
|
But what I expect is, when an object is inserted to a container, the container will call its copy constructor to make a copy and put into the container. Based on the result of my testing, looks like there are more than one copy of the object is created by copy constructor during the "push_back" process, and some of them got deleted, finnally only more copy remained and stored into the container. Looks like the insertion process is more complicated than just a value semantic.
|
|
|
|
|
Does this help? I suspect the additional copies may be the result of calling a function as in this example.
----------------
#include <iostream>
#include <vector>
using namespace std;
class CLogMe
{
public:
CLogMe()
{
cout << "CLogMe()" << endl;
}
CLogMe(const CLogMe &)
{
cout << "CLogMe(const CLogMe &)" << endl;
}
CLogMe& operator=(const CLogMe &)
{
cout << "operator=(const CLogMe &)" << endl;
return *this;
}
};
typedef vector<CLogMe> LogMes;
LogMes g_LogMes;
void Function(CLogMe me)
{
g_LogMes.push_back(me); // CLogMe copy constructor called here.
}
int main(int argc, char* argv[])
{
CLogMe me; // CLogMe constructor called here.
Function(me); // CLogMe copy constructor called here.
return 0;
}
Steve
|
|
|
|
|
This is exactly what I tried. I found the copy constructor get called a lot of time. After 5 push_back, copy constructor get called 20 times, and destroyed 15 times.
|
|
|
|
|
I'd say the additional copies comes from temporaries during the process of adding an element.
--
The Blog: Bits and Pieces
|
|
|
|
|
Ajax95 wrote: the container will call its copy constructor to make a copy and put into the container
The compiler, if any, makes the copy ctor call.
Ajax95 wrote: Based on the result of my testing, looks like there are more than one copy of the object is created by copy constructor during the "push_back" process
Not strange at all. The documented fact for a container with value semantics is that a copy of an element is added. It's not stipulated that one and only one copy will be made during the process and that that single copy is the one to be added. In fact, if you had taken the time to step into the push_back code while debugging, you would have noticed that lots of temporary copies are created during the process, which ensures that the original data is not tampered with.
Ajax95 wrote: some of them got deleted
Of course, that's the temporary ones that goes out of scope at each call return.
Ajax95 wrote: Looks like the insertion process is more complicated than just a value semantic.
No.
--
The Blog: Bits and Pieces
|
|
|
|
|
To avoid these extra copy constructor, call reserve function. like vec.reserve(5);
Everytime you calls push_back, vector has to expand the memory block and copies the elements from the original to new memory block. Here comes the copy constructor in picture. As the size of vector increases, the number of calls of copy constuctor keeps on increasing(directly proportional to number of elements in vector).
|
|
|
|
|
hi all
Following error occur in my atl com project.this project is using both the atl and mfc classes.Tool is visual studio 2003.
d:\Microsoft Visual Studio .NET\Vc7\atlmfc\include\atlcom.h(1759): error C2259: 'ATL::CComObject<base />' : cannot instantiate abstract class
with
[
Base=CMakeBarcode
]
Tasleem arif
|
|
|
|
|
well, once again, your question is very vague, and here, there's even no question. but i guess it is this : "Can anybody help me with this ?"
well, not really much... the compiler is already very explicit... you are creating an ATL::CComObject of a Base object, but as this Base type is an abstract class, you cannot create an instance of it.
you have two choices to solve this :
either you change the Base type and remove its "abstract" behavior, or you pass to the template parameter a child type of Base...
|
|
|
|
|
hi iwant to know where i can get the specification of ATL classes.i mean classes included in the ATL 7.
Tasleem Arif
|
|
|
|
|
|
hi all
i had made applicaton that generate the barcode and now i want the to make it as com component and acces through site. i mean online barcode geneator. it works fine as destop application.
i want to know how to use mfc classes in atl. or these allowed or cannot use these classes in atl 7. im using visual studio.net 2003. and atl 7 project.
ddd
|
|
|
|
|
cross posts are never welcomed
|
|
|
|
|
i dont think that is the cross post.is this atl forum and i want to know how to use mfc classes in atl that is simple question no cross question.
well how to read the text file in ATL i had tried to use the MFC class but it gives error when i use this when i add header file of it then it also give error.
ddd
|
|
|
|
|
do you know what cross-posting is ?
you ask on Visual C++ forum, COM forum, and now ATL forum...
i agree that your question concerns all these categories, but you have to choose the best place to ask, and wait for an answer. only then you can try another forum if you didn't get pertinent solutions...
so, i keep my position, you cross-posted the message boards
|
|
|
|
|
The most important factor is time
i m new to ATL amd COM and dont know the which section is good and secondly i dont know ur answering mechanism u visit all sections or particular. though above question was related to COM and ATL but i got my answer from MFC forum if i dont post there then i should wait the whole day perhaps whole week and so on.
Tasleem arif
-- modified at 9:00 Tuesday 28th March, 2006
|
|
|
|
|
|
Hi all,
Recently I began work localizing my apps. My source of reference is the satdll sample found in MSDN (based on MFC however).
I'm using _Module.SetResourceInstance() to point the app to my external resource dll and it seems to work as my built-in resouces are no longer used. However, the trouble is my new resources in the dll is not showing up as well (all my dialogs are skipped and message strings appear empty).
I've made sure that my resource IDs are the same but I've set the language attribute to something other than English (e.g. my french res dll will have all resources specified as French (France)).
Any advise/pointers is much appreciated.
Cheers
Sidney
--------------------------------------------
Need help with your spelling in the forum?
Check out ieSpell, spell checker addon for Internet Explorer.
|
|
|
|