|
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
|
|
|
|
|
Use an I/O manipulator for that:
cout << hex << x << endl;
--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
|
|
|
|
|
thanks for your help. i knew it had to be something simple
-perseus
|
|
|
|
|
Hi All,
anybody know of some spots on the web to find icons I can use in my programs?
Thank You
|
|
|
|
|
http://www.iconarchive.com
http://www.iconnews.freeserve.co.uk/page2.html
http://www.iconfactory.com
http://groups.yahoo.com/group/glyphs/messages
Should be enough to get ya started
And the clickety police can sod off!
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
|
Hi guys!
I'm a beginner and I have some problems with the project I am working. It's a MDI without doc/view.
I just want to know how I can use a splash screen. I have read that there was a splash screen component in VC++ 6 but I cannot find it in .NET. Also, I want to change the icon and the title of my child windows. I've been able to change the size and the position of my child windows but I can't change the name and the icon.
I used
BOOL OpenGL_ContextMFC::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying theCREATESTRUCT cs
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
cs.lpszName="My new name here doesn't work";
cs.cx = 500;
cs.cy = 500;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
any ideas?
thanks
|
|
|
|
|
Yup there is a splash screen component in VC 6....its very simple to use...
I dunno why u need in .NET.
Then to change the Icon..Its simple...Replace the icon which u want to load with the existing thing in the resource file(.rc)...and i dunno which name ur talking abt.....So be more forthcoming...
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
I have a dialog app that I use to call other dialogs to display and get information.
When a user presses a button I call up a dialog like so:
CMALF2Dlg *pdlg;
pdlg = new CMALF2Dlg;
pdlg->Create(IDD_MALF_2,this);
and when I close the dialog I use:
DestroyWindow();
PostNcDestroy();
delete this;
After doing this it deletes some of the memory, but leaves about 4k out there. After calling and closing a few times it seems to settle at two memory values one before the call and one after. Is this normal or am I missing something here? Maybe I'm missing some other memory management code.
Thanks for the help,
Jim
|
|
|
|
|
Hmmm, delete this should take care of everything, including calling DestroyWindow window, so there's no need to call it yourself.
Anyway, the reason for the memory leak is not apparent, but if you run the app in the debugger and then close it, you should see exactly where the memory that's leaking was allocated.
You may also consider taking a different, simpler approach. But it depends on whether you want to allow the user to create multiple CMALF2Dlg boxes everytime the button is pressed. If you DON'T, then great! I have the perfect solution, create it as a static variable:
static CMALF2Dlg s_dlg;
if (!::IsWindow(s_dlg.m_hWnd))
s_dlg.Create(CMALF2Dlg::IDD, this);
s_dlg.ShowWindow(SW_SHOWNORMAL);
Then you can get rid of the delete this as well as the memory leak.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi!
I want to make a system call to run a C executable from my another c code.
How can I do that?
Thanks
|
|
|
|