|
STL containers don't have virtual destructors, so inheriting from them is, by definition, 'bad practice', although there are always exceptions, pragmatic or otherwise....
If your 'MyClassContainer' isn't actually a 'vector' but uses a vector to implement some other form of container then containment as a member is a good approach. For instance the STL 'stack' is implemented in terms of another container, but not using inheritance. In this case a 'stack' is not a 'vector'.
std::vector has no protected members, and no virtual functions. In this case inheritance seems inappropriate. I would implement your additional functionality as plain old functions that take a reference to a suitable vector as an argument. You could even use some templatry to make things more general,
<br />
template< typename C, typename T> void addT ( C& c, T& t )<br />
{<br />
c.push_back ( t ) ;<br />
}<br />
<br />
vector<MyClass> v ;<br />
addT ( v, MyClass ()) ;<br />
etc.
Paul
|
|
|
|
|
I am using an Sproxy call from an unmanaged C++ DLL to a webservice. In my web.config I am using windows authentication, impersonate = true, and allow users is "*". For the website if the security is set to allow anonymous users, then the component call succeeds. If I turn off anonymous users then the component call fails.
It doesn't appear that the windows identity is being passed with Sproxy. What I had wanted to do was to turn anonymous users off, deny users "*" and allow users "domain/each_user" where "domain/each_user" = the users I wanted to allow access to the service. The method that I describe works if users access the service from their individual IE, but it will not work from the component running on their PC.
Any help would be appreciated.
|
|
|
|
|
Hi,
Assume, I have a parametrized class:
template <class A>
class CBase
{
public:
CBase() {};
~CBase() {};
}
Can I subclass this file as the follows:
template <class A>
class CBaseSub : public CBase <A>
{
public:
CBaseSub() {};
~CBaseSub() {};
}
Visual C++ 6.0 allows such subclassing but Rational Rose 2001 doesn't allow (it told me 'Cannot subclass from parameterized class').
What is true? Can I subclass from parameterized class?
Sincerely Yours,
RadioShark
|
|
|
|
|
The code is perfectly correct. In fact, subclassing from class templates is a fairly common idiom in many situations. UMS is wrong, God knows why.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OnSize() appears to be called after OnDestroy() for the view of a wizard generated ATL/WTL SDI. This is not the case for an MDI.
Anyone else encountered this? This was unexpected behavior, and while it's easy to work around, seems somewhat undesirable.
-john
|
|
|
|
|
Hello, everyone,
In my current project, I want to display xp style button(OK, Cancel and Apply) in the properties sheet.
If I do it using MFC, it would be very easy. I just need to
m_btnXPButton.SubclassWindow(GetDlgItem(ID_APPLY_NOW)->m_hWand);
But when I tried to do the same thing in ATL, the returned handle for ID_APPLY_NOW (IDOK and IDCANCEL) is NULL.
How can I get the handle of a control in the properties sheet written in ATL.
Thanks a lot in advance.
bin
|
|
|
|
|
Hello everyone:
In my pc, VC6.0 has been installed, I downloaded the wtl zip file from
http://www.microsoft.com/downloads/details.aspx?familyid=128E26EE-2112-4CF7-B28E-7727D9A1F288&displaylang=en
and intalled it.
do I need to install other software or SDK ?
Thank you.
-Freehawk
|
|
|
|
|
No, although you might find the Platform SDK useful too.
You will need to make sure the WTL include folder is in the list of folders to search (tools/options/directories).
Steve S
|
|
|
|
|
|
Thank you for the fast reply.
Please tell me Where Platform SDK is.
-Freehawk.
|
|
|
|
|
|
Thank you.
But I dont know what SDK is required by WTL.
Please tell me.
-Freehawk
|
|
|
|
|
No sdk upgrade is required for WTL (afaik). You shouldn't need anything but the WTL.
|
|
|
|
|
Did you run the AppWiz60 setup script? I think that's all you need to do. It should add the directories to the ide.
|
|
|
|
|
Hi,
I am writing a composite ATL control, which is to be used within a larger application context later. With respect to pressing TAB it should behave in the following way :
When the TAB focus gets to the control in the mother app, the first control within the ATL control should get the focus.
Further TAB presses should cycle through the child control within the ATL control until the TAB focus leaves the control, handing the focus back to the mother app.
When the TAB focus enters my ATL control I get the following errors:
Warning: constructing COleException, scode = DISP_E_MEMBERNOTFOUND ($80020003).
First-chance exception at 0x77e9ba9d in FredFirstSteps.exe: Microsoft C++ exception: COleException @ 0x0012f8e0.
Warning: constructing COleException, scode = DISP_E_MEMBERNOTFOUND ($80020003).
First-chance exception at 0x77e9ba9d in FredFirstSteps.exe: Microsoft C++ exception: COleException @ 0x0012f8e0.
Within the ATL control I am using standard MFC control such as CListCtrl and CTabCtrl . The tab control allows me to switch between a list control and my own window - a class derived from CWnd and created with CreateEx that does it's own drawing (a type of diagram).
The user can therefore switch between viewing the data as a list or as a diagram.
This is the code that switched the two views when I get the selchanged from the CTabCtrl
pWnd = m_vctTabWindows[m_iPreviousTab];
pWnd->ShowWindow(SW_HIDE);
m_iPreviousTab = iTab;
pWnd = m_vctTabWindows[m_iPreviousTab];
pWnd->ShowWindow(SW_SHOW);
The TAB order is interrupted in my control when the diagram view is selected. The TAB focus goes to the CTabCtrl , which control which window (list or diagram is to be shown) and from there it should go to the diagram CWnd.
But when the CWnd should have the focus It does not get any keyboard events. I try to intercept the keyboard events in PreTranslateMessage , but nothing happens.
In the CListCtrl derived class I catch the keyboard events in OnKeyDown , where I get the VK_TAB key and switch to the next dialog items using GetNextDlgTabItem followed by SetFocus - that works well.
But the CWnd derived diagram view misbehaves -
Can anyone help with the keyboard focus problem and the TAB exception ?
Thank you very much
Fred Wobus
|
|
|
|
|
Example : some wtl application run ok on windows XP and windows 2000, but there are some bug when it run on windows 98, Me, NT.
did you meet the kind of problem?
what is the possible reason?
Please tell me.
Thank you.
-Freehawk
|
|
|
|
|
I recently added STL vector to some 3D classes I have in order to store a huge amount of datas. I've read somewhere that vector doesn't free object untill it is freed. But I thought that myvector.clear() would free the content.
I just experienced it doesn't:
My classes are prototyped like this:
<br />
class C3dObject<br />
{<br />
public:<br />
C3dObject(TCHAR* pszObjectName);<br />
~C3dObject();<br />
<br />
std::vector<C3dVertex*> m_vctVertex;<br />
}<br />
In the destructor, I just call:
<br />
m_vctVertex.clear();<br />
and this frees nothing (The C3dVertex class has the same prototyping).
Has someone an explanation to this ?
Thanks
Yarp
http://www.senosoft.com/
|
|
|
|
|
oops, my vector class is declared as follows (think it's due to tag like syntax in the vector's declaration):
<br />
std::vector<C3dVertex*> m_vctVertex;<br />
Yarp
http://www.senosoft.com/
|
|
|
|
|
vector doesn't free anything because the things it's storing aren't objects.
You're storing pointers. You'd need to modify it to be:
for( it = m_vctVertex.begin(); it != m_vctVertex.end(); ++it)
{
if (*it) delete (*it);
}
m_vctVertex.clear();
where it is an iterator, as usual. If the thing was an object itself, eg CString or struct xxx or whatever, then it would do what you expect.
Steve S
|
|
|
|
|
|
Thank you both for your explanation.
I thought this had something to do with pointer based vector, I understand why now... and btw Nemanja your article is very interesting.
STL obviously is a very powerfull concept.
Yarp
http://www.senosoft.com/
|
|
|
|
|
Background:
I am working on a system composed primarily of VB 6.0 COM components. I need to add a sub-system of ATL components in order to reuse some C++ code.
Problem:
Reusing the C++ code using ATL and having it interop with VB components requires the use of Automation (oleaut32.dll) compliant types (SAFEARRAYs) and VB compliant types (no unsigned types).
What I would like to do:
Some ATL components will have both VB clients and ATL clients. I would like to define non-VB friendly interfaces to be used by the ATL clients only. Another idea is to create interfaces that are not Automation compatible but mark them as [local] so that no proxy stub is required. I could use these interfaces to pass "non SAFEARRAY" arrays and such.
Do I know enough to shoot myself in the foot? I am afraid that I am making a ATL newby blunder.
Should I just make all the interfaces [oleautomation] and VB compliant? I hate to wrestle with SAFEARRAYs of four Bytes because I can't work with unsigned longs. This is non-risky but inelegant.
|
|
|
|
|
Hi all,
Where can i find atl service s tutorial for the very beginner?
10'x
|
|
|
|
|
I want to use XP-Style in ATL program;
I could make "XP-Style exe program" using manifest file and resource setting;
But in ATL project,I can't that.
I tried all method written MSDN,but I failed.
URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/xptheming.asp
Is this problem solvable?Please teach me.
|
|
|
|
|
Are you running the ATL program on an XP or Win2k3 box? You won't get the XP style on anything less than XP.
|
|
|
|