|
Use CWindow::SetDlgItemText() instead:
SetDlgItemText ( IDC_NAME, _T("Wahoo!!") );
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello All,
In VS.NET General project property page, there is this property
"Use of ATL".
What really is the meaning of this? Even in WTL project generated
with the wizard, this property is set to "Not Using ATL".
This is what the documentation/help has to say:
Use of ATL
Specifies whether the ATL project will statically or dynamically link to the ATL .DLL.
If you specify anything other than Not Using ATL, a define of some kind will be added
to the compiler's Command Line property page.
What is the "define of some kind" that the documentation is refering to here?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
_ATL_DLL - is one of them. The second I do not know.
|
|
|
|
|
Hi
Is QueryInterface call AddRef() ?
STDMETHODIMP CPatternGenerator::GetLayout(long lIndex, ILayout ** pVal)
{
// TODO: Add your implementation code here
if (lIndex >=0 && lIndex < m_vLayoutList.size()){
m_vLayoutList[lIndex]->QueryInterface(IID_ILayout, (void**) pVal);
m_vLayoutList[lIndex]->AddRef(); // Is this statement required.
return S_OK;
}
return E_INVALIDARG;
}
My understanding is that QueryInterface has already called AddRef so we dont need it. Am i correct?
Thanks
Qur
|
|
|
|
|
Yes, the returned interface has incremented the reference count prior to being returned to you.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi
I am new in atl com and little confuse about the reference management.
Here is the code:
typedef stack <CComObject <CLayout> *> LAYOUTSTACK;
typedef vector <CComObject <CLayout> *> LAYOUTVECTOR;
CComObject <clayout> * oLayout;
LAYOUTSTACK sLayout;
sLayout.push (m_opLayout); //where m_opLayout is private memeber
oLayout = sLayout.top();
oLayout->AddRef(); //question: this statement is required or not and why?
m_vLayoutList.push_back(oLayout); //private member of type LAYOUTVECTOR
sLayout.pop();
On general do we need to call AddRef if pointer assignment is done for CComObject <>.
Thanks
Qur
|
|
|
|
|
qur wrote:
do we need to call AddRef if pointer assignment is done for CComObject.
CComObject is not a smart pointer class, so any time you create a new reference to the underlying object, you need to AddRef() it.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
What is the good way to create the coclass object that can take care of reference count.
|
|
|
|
|
Michael Dunn wrote:
CComObject is not a smart pointer class, so any time you create a new reference to the underlying object, you need to AddRef() it.
Ok, not know hardly anything about COM I have a question off this answer. I assume that CComObject is an already wrapped class/object? Otherwise wouldn't you call an AddRef(); function inside your constructor to increment the reference counting? I suppose a more generalized answer to my question would be for me to read more about COM. In due time I suppose.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
ATL abstracts IUnknown implementation in three classes : CComObject / CComAggObject and CComPolyObject - CComObject provides the IUnknown implementation for non-aggregated objects.
|
|
|
|
|
I have to question:
1- If I chose "yes" in aggregation section of ATL Object Wizard then should a create the coclass object using CComAggObject or CComObject?
2- Do same reference counting rules apply when creating coclass object through CComObject as with interface pointers?
Thanx in advance.
qur
|
|
|
|
|
If you choose "yes" for aggregation then your class can run either standalone or aggregated, so you can use both CComObject or CComAggObject ( depending on your needs). And yes , you will have to take care of the object lifetime, addref-ing and releasing properly any object created by CComObject. However, if you just want to create and use an object inside a function you can use CComObjectStack - it doesn't perform reference counting.
|
|
|
|
|
Can I supress the "look if item is still there", when I insert an item into a map?
(I already verified that the item is not there, and want to save the overhead)
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
One solution is a multimap since it allows multiple same elements by design, thus I doubt there is a lookup.
Kuphryn
|
|
|
|
|
The "look if the item is there" is just a byproduct of finding the correct insertion point, so can't really be removed...personally, I wouldn't bother verifying that the item's not in the map, I do something like this:
std::pair<iterator, bool> insertionResult = map.insert(std::make_pair(key, value));
if (!insertionResult.second) insertionResult.first->second = value;
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Stuart Dootson wrote:
is just a byproduct of finding the correct insertion point
good point, it's probaly a silly question.
I have to check if the item is in the map before, it's an "overwrite or add" operation, which needs additional housekeeping if it's an overwrite.
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
maps overwrite by default. IIRC, the return value is a map<T>::value_type which means you can examine what was overwritten.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
There's a version of std::map::insert that accepts an iterator as a hint to the appropriate insertion place. You can take advantage of this if you previously save the position of the immediately preceding element in the map, as the following example shows:
#pragma warning(disable:4786)
#include <map>
using namespace std;
template <class map_type>
map_type::iterator insert_if_not_present(map_type& m,const map_type::value_type& v)
{
map_type::iterator it=m.lower_bound(v.first);
if(it!=m.end()){
if(!m.key_comp()(v.first,it->first)){
return it;
}
}
if(it!=m.begin())--it;
return m.insert(it,v);
}
int main(void)
{
map<int,int> m;
insert_if_not_present(m,make_pair(1,1));
insert_if_not_present(m,make_pair(2,2));
insert_if_not_present(m,make_pair(3,3));
insert_if_not_present(m,make_pair(2,2));
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
I'm developing ATL ActiveX EXE server that runs as a Window services using ATL wizard.
This server contains one ATL object (CTest).
How I can set the server so that when it started (via Window Services Applet), the server will :
1) initiate/create CTest.
2) Call method/function in this ATL object (CallMe).
3) destroy CTest when server stopped.
Thanx in advance.
Regards.
|
|
|
|
|
Hi.
How do you definte a comparison function for an container of std::pair other than map? I need to search a container of std::pair. For example:
typedef std::deque<std::pair<std::string, int=""> > deqStringInt;
deqStringInt example;
example.push_back(std::pair<"December", 21>);
// How do you search an element?
std::find_if(example.begin(), example.end(), std::bind2nd(???
// Functor
class Search : std::binary_function<std::pair<std::string, int="">, std::string, bool>
{
public:
bool operator()(const std::pair<std::string, int=""> &lp, const std::string &rp)
{
return lp->first == rp;
}
};
Thanks,
Kuphryn
|
|
|
|
|
#pragma warning(disable:4786)
#include <queue>
#include <string>
#include <algorithm>
typedef std::deque<std::pair<std::string,int> > deqStringInt;
struct my_search
{
my_search(const std::string s):s(s){}
bool operator()(const std::pair<std::string,int>& c) const
{
return c.first==s;
}
private:
std::string s;
};
int main(void)
{
deqStringInt example;
example.push_back(std::make_pair(std::string("December"), 21));
std::find_if(example.begin(),example.end(),my_search("December"));
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nice! Thanks.
Here is another solution and the one I implemented.
class Searc : std::binary_function<pairstringint, std::string,="" bool="">
{
public:
bool operator()(const pairStringInt &lp, const std::string &rp) const
{
return (lp.first == rp);
}
};
std::find_if(data.begin(), data.end(), std::bind2nd(Search(), theString))
Kuphryn
|
|
|
|
|
Hi.
Is it possible to have an unsorted map and/or multimap STL container? The map is an extremely useful STL container because of its key and value feature. I need to set a map container to not sort its keys, i.e. insert them if they do not exist, but in a queue fashion as in FIFO.
Thanks,
Kuphryn
|
|
|
|
|
Just combine the key and value into another structure/class or use std::pair and then use std::deque as your container. It works well as a FIFO where as by definition, a map is sorted and would perform poorly as a FIFO.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Nice! Thanks
Can you give a quick example of std::pair in other containers beside the map? I did not know it was possible to use std::pair as a datatype. How about searches?
Kuphryn
|
|
|
|