|
But, if I'm not wrong, IUnknown methods are virtual, you can safely override them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes i know, but i am afraid that somewhere else in ATL code there is
a pointer to CComObject (the most derived class) so i want to be sure that
every call to Release will be to overwritten one.
|
|
|
|
|
Ok, now I think I know what you're after. You can arrange things by laying down the following hierarchy:
template <class ThreadModel> class CMyComRoot: public CComObjectRootEx<ThreadModel>
{
};
class CMyCom: public CMyComRoot<ThreadModel>, public CComObject<CMyCom>
{
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
My COM object can overwrite InternalRelease. However, CMyCOM can't inherit from CComObject. On the contrary, CComobject inherits from CMyCOM.
If you look in <atlcom.h> you can see that CComObject derives from a COM object. It is the most derived class.
ATL sometimes works with the pointer to CComObject<> .
Therefore, i have to define explicit specialization to that template.
What is the meaning to:
error C2934: 'CComObject<class cmycom="">' : template-class-id redefined as a nested 'class' of '<unknown>'?
|
|
|
|
|
From the end of your post to the beginning
error C2934: 'CComObject' : template-class-id redefined as a nested 'class' of ''?
Basically, it means that you cannot specialize this, I guess because full specialization implies instantiation, and this can't be done (the same way as CComObject<CComObjectRoot> cannot be instantiated directly).
My COM object can overwrite InternalRelease. However, CMyCOM can't inherit from CComObject. On the contrary, CComobject inherits from CMyCOM.
So, if I' understanding now your intention, CMyCom is meant as a replacement for CComObjectRoot and family, right? Then, cannot you just provide a suitable InternalRelease implementation and forget about specializing?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
CMyCOM is derived from CComObjectRoot family.
i can overwrite InternalRelease but it cann't help.
Here is the code of CComObject::Release:
STDMETHOD_(ULONG, Release)()
{
ULONG l = InternalRelease();
if (l == 0)
delete this;
return l;
}
CComObject::Release method decides whether to delete the object or not.
Therefore, overwriting InternalRelease can't help.
So what else can i do?
|
|
|
|
|
Maybe you can return a non-zero value from InternalRelease , as the life-tracking of your objects is handled internally.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I thought about that, but the CComObject::Release should return the object to the pool instead of deleting it.
CComObject::Release should check if the reference counter is 1 then the object should be returned to the pool. (Intead of deleting it when the counter is 0).
Therefore, i must change CComObject::Release implementation.
|
|
|
|
|
I have a simple dialog and a problem with ShowWindow where EnableWindow seems to work perfectly.
Specifically, the following code works perfectly:
if(strHelpID.IsEmpty())<br />
GetDlgItem(IDC_BTN_MORE).EnableWindow(FALSE);<br />
else<br />
GetDlgItem(IDC_BTN_MORE).EnableWindow(TRUE);
However the following code:
if(strHelpID.IsEmpty())<br />
GetDlgItem(IDC_BTN_MORE).ShowWindow(SW_HIDE);<br />
else<br />
GetDlgItem(IDC_BTN_MORE).ShowWindow(SW_SHOW);
causes the dialog display to go "snaky" and areas of the dialog become blank, all buttons disappear, static text boxes go blank, the background paints over everything (intermittently), in other words controls on the dialog not related to the code above for a single button are affected in how they draw.
The code above is called by the user clicking on a button which shows a tip of the day so it's not tied to an event or windows message of any kind (other than the user clicking on a button).
(This is ATL 7.0)
|
|
|
|
|
hi,
I need a help !! Please someone help me !
I am developing ATL COM which contains property of type COM object (ATL coclass): CComObject<dombookingareaholder> *m_AreaHolder.
Just for info: domBookingAreaHolder is a ATL co class.
I want to allow all clients (C++, VB, VBSCript) to be able to get and put the property.
Below is the code for ATL COM:
1) domBooking.CPP
<br />
<br />
class ATL_NO_VTABLE domBooking : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<domBooking, &CLSID_domBooking>,<br />
public ISupportErrorInfo,<br />
public IDispatchImpl<IdomBooking, &IID_IdomBooking, &LIBID_DOMIBMSLib><br />
{<br />
public:<br />
domBooking()<br />
{<br />
}<br />
<br />
HRESULT FinalConstruct()<br />
{<br />
CComObject<domBookingAreaHolder>::CreateInstance(&m_AreaHolder);<br />
return S_OK;<br />
}<br />
<br />
void FinalRelease()<br />
{ <br />
m_AreaHolder = NULL;<br />
}<br />
<br />
DECLARE_REGISTRY_RESOURCEID(IDR_DOMBOOKING)<br />
<br />
DECLARE_PROTECT_FINAL_CONSTRUCT()<br />
<br />
BEGIN_COM_MAP(domBooking)<br />
COM_INTERFACE_ENTRY(IdomBooking)<br />
COM_INTERFACE_ENTRY(IDispatch) <br />
END_COM_MAP()<br />
<br />
public:<br />
<br />
STDMETHOD(get_AreaHolder)(IDispatch*** pVal);<br />
STDMETHOD(put_AreaHolder)(IDispatch** newVal);<br />
<br />
<big>CComObject<domBookingAreaHolder> *m_AreaHolder;</big><br />
<br />
};<br />
<br />
1) How I can accomplish this ?
2) how the propety for get and set being implemeted ?
3) and lastly how client can call to object property using set and put in VC++ ?
Thank u very very much in advance . Any advice and suggestions strongly aprreciated.
Regards,
Newbie
|
|
|
|
|
|
HRESULT get_AreaHolder(IDispatch*** pVal)
{
return m_AreaHolder->QueryInterface(IID_IDispatch, (void**)pVal);
}
|
|
|
|
|
Hello, everybody!
How to do a dockable toolbox like in Visual Studio???? pls help
|
|
|
|
|
Hello, everybody!
How to do a dockable toolbox like in Visual Studio???? pls help
|
|
|
|
|
Do you mean WTL Docking Windows[^] or did you have something else in mind? If so, please explain more precisely.
|
|
|
|
|
.....i mean toolbar...command bar... etc
Ed Gadziemski wrote:
Do you mean WTL Docking Windows[^] or did you have something else in mind? If so, please explain more precisely.
|
|
|
|
|
Use the project wizard to create a WTL SDI or MDI application. Accept the default settings and it will create a command bar for you.
|
|
|
|
|
Hi.
How do you know if find() returns a valid element in a map that is inside a map? For example:
-----
typedef std::map<<int, int="">> mapIntInt;
typedef std::map<<double, mapintint="">> mapDM;
mapIntInt mapOne;
mapOne.insert(std::pair<<int, int="">>(0, 1));
mapDM mapTwo;
mapTwo.insert(std::pair<<double, mapintint="">>(8.9, mapOne));
// Now I want to search mapOne, but first I need to search mapTwo for mapOne.
if (twoIterator != mapTwo.end())
{
oneIterator = twoIterator->second.find(8.9);
// How do you check if oneIterator points to a valid element?
}
-----
Given the example above, how do you know what if the search in the second map container (map inside of map) points to a valid element?
Thanks,
Kuphryn
|
|
|
|
|
if(oneIterator!=twoIterator->second.end()){...}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
How to output string into a file? My part of code is belowLook at the last line, it is not ok.)
// Open the file ready write
if((pOutputFileStream = fopen(csFilePath, "w")) != NULL)
bStatus = TRUE;
// Otherwise output message to the console window.
else
{
printf("The output %s file is not available!", csFilePath);
bStatus = FALSE;
}
if (bStatus)
{
// STL string.
string str = vNode.back ();
cout << str << endl;
//
// this line is not ok.
//
fprintf(pOutputFileStream, "%s", str.substr);
}
Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
You're using C++ to output to the console, and C to output to the file. Use iostreams instead.
#include <iostream>
#include <fstream>
#include <string>
using std::string;
using std::ofstream;
...
string s("This is a test of the veracity of my system");
ofstream op("c:\\test.txt");
op << s;
// can call op.close(), but the destructor does it anyhow.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hello,
My projects doesn't seem to be using MFC, although I made a redist. of my project and I get an error on MSVCR70.dll
In my project settings, in: Use Of MFC, I have: Use Standard Windows Librairies.
Why do I have a dependency on MFC anyways???
Thanks!
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|
|
Um, MSVCR70 isn't MFC, it is part of the C runtime library. If you want to get rid of that, build the project using static libraries and not dynamic.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Where do I set that? In: Use of ATL I have: Static link to ATL already...
Thanks!
EDIT: I think I found it... it's in Minimise CRT use in ATL...
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|