|
i am also new to ATL but i can help you a bit..
see IE toolbar tutorials
http://www.codeproject.com/useritems/toolband.asp
http://www.codeproject.com/shell/2find.asp
Erik's tutorial tells us how to use his deskband and CWindowImpl Classes. I guess you haven't gone deep. I hope now these 2 tutorials will help you in doing what you wish to do.
cheers..
Himanshu
|
|
|
|
|
It's better to show me the sample-code or step.
ANYWAY,Thanks for your reply!
|
|
|
|
|
Wrong forum!!!
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Here is what I mean abstractly: I have a project that has 3 class, each defined in its own header.
Class A has a variable of class B, and class B has a variable of class C. What I need to do is pass down the "this" pointer from class A to class C, so that class C can interact with some of the memebers of A. To do this, I have to pass it through B then to C. Also, class C's header file needs to include A's, and so does B.
The problem is that when I include "ClassA.h" in "ClassC.h", I get C2079 errors saying that class C is not defined, when I make an instance of class C inside class B. I realize what is going on here (correct me if I am wrong) is that MSVC gets a little confused when I have the include's tangled up like this (C includes A which includes B which includes C AND A, even though I am most definately using #ifndef)
Make any sense? I have seen this error a lot in the past, usually predeclaring all involved classes before making any include directives fixes this, but this time around that isnt working. Is there a fairly simple solution to this? I am using .NET, unmannaged C++, and I also tried using precompiled headers (and no, I am not using MFC, this is a straight up console app that is later going to be turned into a lib once I am done testing everything).
(maybe this is neater)
ClassA.h includes ClassB.h, and class A has a variable of class B
ClassB.h includes ClassA.h and ClassC.h, and class B has a variable of class C. One of the methods of class B takes a pointer to a variable of class A
ClassC.h includes ClassB.h and ClassA.h, and has a method that takes a pointer to a variable of class A.
|
|
|
|
|
|
Can anyone tell me how and if you can derive a template clkass from another template class? I do not know how to declare this (syntax) if this is possible.
Also, is it possible to make a template class inherit from one that was not a tempalte class?
Thanks in advance.
|
|
|
|
|
Try
template<typename T>
class A
{
// Blah
};
template<typename T>
class B : public A<T>
{
// Blah
};
Template classes can inherit from non-template classes (using standard syntax).
Dave
|
|
|
|
|
Actually, when you derive from a template class you don't use the template keyword if the derived class has no template params of its own. In ATL you do this:
class CSomeWnd : public CWindowImpl<CSomeWnd>
{ ... }; all the time
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Actually, The derived and the base has the same template params.
template <class type="">
class CBaseClass
{
}
what would the derived class look like?
I want to use a template class as a param in the other template class.
I am really not sure how the syntax goes with this.
class CClass: public CBaseClass<x>
{
}
will give errors as to what X is.
I get a LINK2001 when I put
template <class type="">
class CClass:public CBaseClass<type>
{
}
So how do I declare this?
|
|
|
|
|
(Note for the future: you need to escape < and > (use the buttons below the sig box if you're in IE/Mozilla) for template syntax to appear correctly.)
There are two ways to approach deriving from a template class. 1, you can make the derived class a template; or 2, you can derive from a specialization of the base class. Take this class:
template <typename T>
class A
{
public:
A ( T t ) : m_t(t) { }
T m_t;
};
A<char> a_obj('x'); Pretty simple class with one data member, whose type is passed as the template param. If I want to make a derived class, I can write this:
class B : public A<int>
{
public:
B(int n) : A<int>(n) { }
};
B b_obj(1); Note that objects of type class B will only use the A<int> specialization. You can't have a class B object use, say A<unsigned long> .
The other way is to have the derived class be a template:
template <typename T>
class C : public A<T>
{
public:
C(T t) : A<T>(t) { }
};
C<double> c_obj(3.14); Of course, you can always make the derived class more complicated if you need to:
template <typename T, typename U>
class D : public A<T>
{
public:
D(T t) : A<T>(t), m_u(0) { }
U m_u;
};
D<float,int> d_obj(2.71828); Yes, the syntax sucks. You just have to keep staring at it and seeing examples until it sinks in.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I am still not g etting this. I am tons of errors. What is the syntax if you declare the class functions outside the template class itself? Where can I look up more examples or a tutorial on this? I have been looking but seem not to be able to find anything on this subject, only on direct use and declarations of templates not deriving from templates.
THanks.
|
|
|
|
|
Errors with what? With your own code? In that case you need to post the code and the errors you're getting.
It'd probably be best to start a new thread, since this one is well-buried by now.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Agreed. But the original question asked how to derive a template class from another template class, not a non-template class from a template class as you have done here.
Dave
|
|
|
|
|
Hello,evryone! this is the first time i come to a foreign forum,
I am a chinese, and english is poor, you can realize it from my words. ^_^
i want to learn english and programming here,so it's only a try. please help me over time!
Hello!
|
|
|
|
|
Hi, I wonder what's fastest to check if a child control (hWnd) is visible?
IsWindowVisible(hWnd) -or-
GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE
First line checks specified window, its parent window (its parent's parent window and so forth) have the WS_VISIBLE style. Second line checks only the specified window. When I check I already know that parent etc is visible, so is second line the fastest solution?
Thx, Moak
|
|
|
|
|
hm, I'll take GetWindowLong()
|
|
|
|
|
Ok.. I dug out one of my old VC++ books Inside Visual C++ Version 4. I read the section on dlls after post many questions here and I still can't seem to get a pointer to my function. Following is the code I am using if anyone has any ideas it would be appreciated.
Thanks,
-Eric
Created this dll using the dllWizard as a shared MFC regular dll.<br />
This is the only exported function in the dll.<br />
__declspec(dllexport) CString SndMessage(CString strInMessage)<br />
{<br />
CString strOutMessage = _T("Inside TestDll.dll->SndMessage() ");<br />
<br />
strOutMessage += strInMessage;<br />
<br />
return strOutMessage;<br />
}<br />
<br />
This is in the Dialog header file as public.<br />
typedef CString (SNDMESSAGE)(CString);<br />
HINSTANCE hDllHandle;<br />
SNDMESSAGE *fpFunction;<br />
<br />
Inside my OnInitdialog().<br />
hDllHandle = ::LoadLibrary(_T("TestDll.dll"));<br />
if(hDllHandle == NULL)<br />
MessageBox(_T("Error loading TestDll.dll"));<br />
else<br />
{<br />
fpFunction = (SNDMESSAGE *)::GetProcAddress((HMODULE)hDllHandle, "SndMessage");<br />
<br />
if(fpFunction == NULL)<br />
{<br />
MessageBox(_T("Error obtaining address of SndMessage() in TestDll.dll"));<br />
PostMessage(WM_QUIT);<br />
}<br />
}<br />
<br />
void CTestingDllDlg::OnButtonTest() <br />
{<br />
UpdateData(TRUE);<br />
<br />
m_strOutText = (*fpFunction)(m_strInText);<br />
<br />
UpdateData(FALSE);<br />
}<br />
<br />
|
|
|
|
|
The problem is you are exporting a C++ function and its name to the outside world is not SndMessage. C++ mangles the name of functions so that the arguments types are included. If you have successfully built your DLL you can find out exactly what the exported name is by typing "dumpbin /EXPORTS TestDll.dll" Dumpbin is one of the VC++ tools.
One work around is to export a straight C function that exports a pointer to the string that is passed via a LONG and you cast it to a string pointer when you use it. This can be wrapped in a local C++ function so don't see the messy details.
Note - in your current implementation, I believe that strOutMesage will be destroyed when SndMessage returns since it is then out of scope.
The Ten Commandments For C Programmers
|
|
|
|
|
Rick York wrote:
The problem is you are exporting a C++ function and its name to the outside world is not SndMessage. C++ mangles the name of functions so that the arguments types are included. If you have successfully built your DLL you can find out exactly what the exported name is by typing "dumpbin /EXPORTS TestDll.dll" Dumpbin is one of the VC++ tools.
One work around is to export a straight C function that exports a pointer to the string that is passed via a LONG and you cast it to a string pointer when you use it. This can be wrapped in a local C++ function so don't see the messy details.
When I run Dumpbin this is what I get:
Dump of file TestDll.dll
File Type: DLL
Section contains the following exports for TestDll.dll
0 characteristics
3E1E3F7D time date stamp Thu Jan 09 22:35:25 2003
0.00 version
1 ordinal base
0 number of functions
0 number of names
ordinal hint RVA name
Summary
F000 .data
5000 .idata
11000 .rdata
C000 .reloc
4000 .rsrc
10F000 .text
Rick, any chance you can explain the second part of that to me?
Thanks,
-Eric
|
|
|
|
|
It sounds to me like you need to use a .def file. I'm not positive, but if it's the GetProcAddress that's failing, this is probably the case.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Change:
__declspec(dllexport) CString SndMessage(CString strInMessage)
to:
extern "C" __declspec(dllexport) CString SndMessage(CString strInMessage)
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I think this would help but I think the CString created will be gone once it is out of scope. I think the CString needs to be new-ed and passed as a pointer.
The Ten Commandments For C Programmers
|
|
|
|
|
What is OLE object? How to create it in VC++?
|
|
|
|
|
|
Can someone please help!!
When I try and displays numbers in hex using the setf(ios::hex) member function of the cout stream class with the string class header defined the numbers do not display in HEX.
the following code works and the number display correctly in hex
#include <iostream.h>
//#include <string>
//using namespace std;
int main()
{
int x = 0xff;
cout<<x<<endl;
cout.setf(ios::hex);
cout<<x<<endl;
return 0;
}
but when i try this the number does not display in hex
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x = 0xff;
cout<<x<<endl;
cout.setf(ios::hex);
cout<<x<<endl;
return 0;
}
Can someone please explain???
thanks
-perseus
|
|
|
|