|
toxcct wrote:
As i never did this before, i wonder how i can load what i put in a dll into the exe project... of course, i would prefer a dynamic link...
thats very simple, when ever you need just mail me! i am always on your side!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
sure, but posting on the forum would permit everybody to aknowledge on the subject...
however, i just found smth interresting on that point, so i think i have enough infos for the moment to realize this.
thx anyway.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi Tox,
toxcct wrote:
As i never did this before, i wonder how i can load what i put in a dll into the exe project... of course, i would prefer a dynamic link...
What do you mean by that ? Maybe I can help 'cause I'm quite familiar with dynamic loading of dll's...
Just let me know if I can help.
|
|
|
|
|
actually, i am expecting to separate the parser of my VisualCalc into its own class, but deported toward a new DLL.
but as i never made MFC DLLs, and never called DLL into a MFC program, i don't know how to do this.
but as i said to Alok, a teacher gave me today a good tutorial on the subject, so i'll try it when i have some time (on evening)...
now, you say you're familiar with dynamic loaded library ; i accept any advice on that coding, even if i found how to solve my problem...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
cedric moonen wrote:
I'm quite familiar with dynamic loading of dll's...
Me too... But i believe you got much more Knowledge in this and almost every regard!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
If I want an STL list to contain either ints or floats and I want to allow the user to make the decision at runtime (i.e. via a prompt) who can I accomplish that? Pseudo:
list myList;
if (user_says_int)
myList = list<int>;
else
myList = list<float>;
|
|
|
|
|
i don't know if there's a more simple way ; here is what i suggest. Make some wrappers for the types you want to decide on, and each should inherit from a base class :
class Types {
};
class Integer : public Types {
public:
int Value;
int operator int() { return Value; }
};
class Float : public Types {
public:
float Value;
float operator float() { return Value; }
};
then, your list will always be a list<Types> but the polymorphism will allow you to use either int or float...
see what i mean ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
see what i mean ?
Yes, but it probably doesn't work as desired. You can insert 'Types' objects into the list but cannot do much with them afterwards.
|
|
|
|
|
Roland Pibinger wrote:
You can insert 'Types' objects into the list but cannot do much with them afterwards
sure you can, as Integer and Float classes inherit from Types , a list of Types will be a list of Integer s and/or Float s...
list<Types> myList;
Integer i = 5;
Float f = 2.1;
myList.add(i);
myList.add(f);
of course, the Types, Integer and Float classes must provide the necessary functions sur as constructors, operator=, etc...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
No, that won't work. You need pointers to Types (or references, but you can't put those in containers) in order to use polymorphism. Use something like:
<br />
list<Type*> theList;<br />
theList.push_back(new Int(5));<br />
theList.push_back(new Float(2.1));<br />
Of course, you need to manage the pointers so that the memory's not leaked (storing boost::shared_ptr<Type> would be my preferred approach)
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I recommend using something like a clone smart pointer instead of a share_ptr. A clone pointer doesn't share it's pointer, so you can copy it from one part of the container to another, without having multiple parts of your container pointing to the same data.
See following link:
http://www.codeproject.com/vcpp/stl/clone_ptr.asp[^]
The above clone pointer not only will transfer from one part of the container to the next, but it also has many of it's operators dereferencing the pointer, so it acts like a concrete type.
#include <clone_ptr.h>
list<clone_ptr<type> > theList;
theList.push_back(new Int(5));
theList.push_back(new Float(2.1));
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
Horses for courses, really - in this case, you're right, you'd likely be better off using copyies of the data. There are, of course, other times when (for whatever reason) you don't want to be copying stuff around.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Cans someone please tell me what is the difference between ALT and COM.
I have a book called "Begging ALT COM Programming", but it doesn't clearly defined the differences between what is ALT and what is COM.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
ATL is a template library that makes it heaps easier to write COM components.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Or, in other words than Christian says, the COM is a technology, while the ATL is a tool.
COM defines some rules (like that objects are refcounted etc.) while ATL helps you to implement these rules, saving you a time by providing helpers for keeping the rules etc.
compare:
creating the com object without ATL:
<br />
IMyInterface* ipNewObject = NULL;<br />
HRESULT hr = CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IMyInterface, &ipNewObject );<br />
if( ipNewObject )<br />
{<br />
ipNewObject->SomeFunction();<br />
ipNewObject->Release();<br />
}<br />
return;<br />
with ATL:
<br />
CComPtr<IMyInterface> spNewObject;<br />
spNewObject.CreateInstance("objectId");<br />
if( spNewObject )<br />
spNewObject->SomeFunction();<br />
return;<br />
|
|
|
|
|
ATL is not only a tool for building COM servers and COM clients, but is also a tiny GUI toolkit. WTL extends the GUI toolkit, making it complete and suitable for application programming.
Good music: In my rosary[^]
|
|
|
|
|
Axter wrote:
Cans someone please tell me what is the difference between ALT and COM.
yeap many!...
COM is just a protocol set for making language independent component and ATL is one technique that use to create com objects.......
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello everyone,
i'm trying to re-write a code from MFC to WTL but that seems not to work so... for exemple:
CString str(_T("some text"));
string st=str;
That has worked in MFC; with WTL, i have the message:
error C2440: 'initialisation' : impossible to convert from 'ATL::CString' to 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
Can someone help me?
Madjid.
|
|
|
|
|
Out of interest, what happens if you change the line to
string st = (LPCTSTR)str;
Steve S
Developer for hire!
|
|
|
|
|
As Steve S points out, you probably need an explicit cast. Another thing to watch for is if you are compiling a Unicode app, then you should use std::wstring instead of std::string.
|
|
|
|
|
With CString, one should do something like this:
typedef std::basic_string<TCHAR> tstring;
Then tstring will be UNICODE when CString is, and isn't.
Good music: In my rosary[^]
|
|
|
|
|
Thankh everybody!
With:
string st = (LPCTSTR)str;
the same problem... if i use wstring, it works. The problem is that i'm obliged to wotk with string,and to convert from wstring to string, i really don't know how!!
|
|
|
|
|
You can use the MS string conversion macros.
If you are using Visual Studio 2002/2003 then you can do this:
string strA = "ascii";
CA2W pszUnicode(strA.c_str());
wstring strW = pszUnicode.m_psz;
...
wstring strW = L"unicode";
CW2A pszASCII(strW.c_str());
string strA = pszASCII.m_psz;
If you are using Visual Studio 6, then you can do this:
USES_CONVERSION;
...
string strA = "ascii";
const wchar_t* pszUnicode = A2CW(strA.c_str());
wstring strW = pszUnicode;
...
wstring strW = L"unicode";
const char* pszASCII = W2CA(strW.c_str());
string strA = pszASCII;
HTH.
|
|
|
|
|
Yeh, I have a whole <tstring> header file containing useful typedefs and inline functions. However, as I _always_ compile for Unicode only nowadays, I am back in the loving arms of wstring...
|
|
|
|
|
I'm also _UNICODE, but I always keep my options open, just in case.
Good music: In my rosary[^]
|
|
|
|