|
Thanks for the help.
-:KNOX:-
|
|
|
|
|
You are always welcome
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Hello!
I have a simple application done with VC++ (2003 .NET). I made simple dialog based application with some buttons (with resource editor). Now I want to do something with images and want to try cool code with CImage class. By MSDN documentation I have to to include
<br />
#include "afxstr.h" (I replaced <> with " so it can be seen in this post)<br />
#include "atlimage.h"<br />
in that exact order. Project setting is "Use MFC in shared DLL". When I do this I get many linker errors like
<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(strftime.obj) : error LNK2005: _strftime already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in msvcrtd.lib(MSVCR71D.dll)<br />
zlib.lib(minigzip.obj) : error LNK2005: _error already defined in webServer.lib(uemf.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __stricmp already defined in LIBCMTD.lib(stricmp.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __strnicmp already defined in LIBCMTD.lib(strnicmp.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __write already defined in LIBCMTD.lib(write.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: _tolower already defined in LIBCMTD.lib(tolower.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: _strcspn already defined in LIBCMTD.lib(strcspn.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __setmbcp already defined in LIBCMTD.lib(mbctype.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __osplatform already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __itoa already defined in LIBCMTD.lib(xtoa.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __lseek already defined in LIBCMTD.lib(lseek.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __unlink already defined in LIBCMTD.lib(unlink.obj)<br />
what can I do. Can I include CImage some other way? Please help!
Best regards,
Rostfrei
|
|
|
|
|
all static libraries must use the same runtime libraries as your application. if you are using MFC in a DLL in your EXE, the .LIBs must all be built with the "multi-threaded DLL" setting; if you are using statically-linked MFC in your EXE, the .LIBs must all be built with the "multi-threaded" CRT.
see the Code Generation option in the library's C/C++ Properties.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I made sure that all files are compiled with "Use MFC in a Shared DLL" option and they all have "Multi-threaded Debug DLL (/MDd)" runtime library selected and I still have linker errors. If I comment includes
<br />
#include <afxstr.h><br />
#include <atlimage.h><br />
there is no link errors anymore.
Any idea?
Regards,
Rostfrei
|
|
|
|
|
May be Try with giving complete path..
ex: "..\afxstr.h"
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
I have developed a COM component using visual studio 7. There is an exposed class that exports some functions and get/sets respectively. I developed this component in two phases. The first phase was designed as a render component. It worked with VB-6, VB.NET CSharp. I appended a Print facility to this component and it works fine under VB.NET and CSharp, however when I run a test harness under VB6 I get problems. It seems VB6 cannot access the Print facilities that I added to this module.
Can anyone tell me what would be causing this to work in VB.NET and C Sharp but not in VB6?
Thank you for your time.
Dave
|
|
|
|
|
It would be nice if you can provide more info.
What is the error you are getting?
what line of code is failing? etc....
rgds...Milon KB.
|
|
|
|
|
I am sorry for not supplying enough information.
I did however manage to find an article that described the problem. It has to do with VB6 and reserved names. My COM Object exported a method named Print. This is a reserved word in VB6 and therefore did not evaluate at runtime.
Quoting from the Net
"There exists a bug in VB6 (and earlier, I assume) that
when you reference a library in the Project Properties and
you attempt to call a method within this object that has
the same name as a reserved word, you get the
error "Object does not support this property or method."
|
|
|
|
|
Hi,
I have been doing an application that contains flex grid control in which there are details about student marks in various subjects.I want to access the data from the flexgrid control regarding a student in the second dialog window which contains the editboxes of different subjects.Now my doubt is how can i move forward to access the student marks from the control to the next dialog window by giving the particular student name in the first dialog window.
|
|
|
|
|
My SpinButtonCtrl runs correctly, but I can not exceed the number of 16960 when clicking the up-arrow.
I use an Editbox and a vertical Spinbutton.
Need a new idea.
Thanks
|
|
|
|
|
|
Hi Chris,
thanks for answer.
Pleas see Code:
BOOL CSPINDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDC_SPIN
CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN);
pSpin->SetRange(0, 1000000); // what I want
iStart = 16900; // to if more than 16960 is possible
pSpin->SetPos((int) (iStart));
UpdateData(FALSE);
double dPos = pSpin->GetPos();
// Editbox
CWnd* pEdit = GetDlgItem(IDC_BUDDY_SPIN);
CString strValue;
strValue.Format("%u", iStart );
pEdit->SetWindowText(strValue);
...
}
void CSPINDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
if (nSBCode == SB_ENDSCROLL)
{
return; // falsche Nachrichten zurückweisen
}
if (pScrollBar->GetDlgCtrlID() == IDC_SPIN)
{
CString strValue;
strValue.Format("%u", (int) nPos );
((CSpinButtonCtrl*) pScrollBar)->GetBuddy()->SetWindowText(strValue);
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
|
|
|
|
|
|
Dear Chris, the first winner,
thank you very much, it works!!! (no sun today here...)
|
|
|
|
|
|
Dear Mike,
thank you very much, it works!!! (no sun today here...)
|
|
|
|
|
Hello,
Class 'Base' has abstract operations that I want to call in the 'Base' constructor; the implementation of the abstract operations should be in Class 'Derived'.
It doesn't work. How can I solve this?
I tried the approach of not using abstract base operations as well. Then only the base operations but not the derived operations will be called.
class Base {
public:
Base(){
a();
b();
};
virtual ~Base();
protected:
virtual void a() = 0;
virtual void b() = 0;
};
class Derived {
protected:
void a(){ }
void b(){ }
};
|
|
|
|
|
|
Oh sorry, I forgot to implement the inheritance in the example code. But it's existing in the real code.
|
|
|
|
|
boogalo79 wrote: Then only the base operations but not the derived operations will be called
how can you say that only the Base class member functions are called, when they are pure virtual function (no body to define them...)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
You will not get the result you hope for if you call a virtual function from a constructor. It's because the virtual table isn't fully set up until the contructor call returns. There is nothing you can do about it. Try something like:
class Base {
public:
base(){}
virtual void Init() { a(); b();}
};
...or make an object factory class which does just that.
|
|
|
|
|
Thank you,
I implemented your suggestion. Now it's working.
|
|
|
|
|
Oh.. really good one.
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Even after you've implemented toxcct's solution, calling virtual functions in a constructor is bad practice and a recipe for disaster. Consider the following code:
#include "stdafx.h"
#include <iostream>
using namespace std;
class Base
{
public:
Base()
{
LogClass();
}
virtual LogClass()
{
cout << "Base" << endl;
}
};
class Derived : public Base
{
public:
virtual LogClass()
{
cout << "Derived" << endl;
}
};
int main(int argc, char* argv[])
{
Derived d;
d.LogClass();
return 0;
}
The output of this program is:
Base
Derived
And not, as you may expect:
Derived
Derived
There are languages where the second is produced in code like this (like C# I believe); they've got it wrong. The reason for this behaviour is that the constructor of a class builds the environment the member functions of that class require; they setup the classes’ invariants. For example for a logging class it may open a file and set a member variable to the file handle; all the classes' functions expect it. This means it is wrong to call a classes member functions before its constructor has been called. In our example the class Derived is only partially constructed; the Derived constructor hasn't been called yet so we can't call its member functions; the virtual function call mechanism makes sure this can't happen accidently.
Steve
|
|
|
|