|
Both are multithreaded.
However, I found that linking with the MFC DLL causes linker errors, and linking statically does not. My guess is that for some weird reason (a bug?), the MFC DLLs export some STL symbols.
|
|
|
|
|
I just dont get it, WTL´s DDX facilities define a DDX_CONTROL() macro that take an ID for a control, and an object to attach it to.
However, if i do something like this:
BEGIN_DDX_MAP(CMyDlg)
DDX_CONTROL(IDC_MYEDIT, m_cEdit)
END_DDX_MAP()
where IDC_MYEDIT is (of course) and edit box on my dialog, and m_cEdit is a member variable of type CEdit, then this class wont complie! because SubClassWindow() (witch is called by ddx), is NOT a member of CEdit!, i suppose i could write a class derived from CWindowImpl<derivedclass, cedit=""> and pass objects of it to DDX_CONTROL(), but i assumed that the whole purpuse of DDX was to make mi life easyer not harder!, it would be FAR more trouble to write a class for EVERY type of control i want to use DDX with, than just create control class member variables on my dialog, and just Attach() them to the "physical" controls on the dialog, early on my OnInitDialog() function!
Im i missing something???
what is the purpuse of DDX_CONTROL() if it CANT be used "normally" with controls?
|
|
|
|
|
DDX_CONTROL requires a class with a message map, that is, a CWindowImpl -derived class. The control wrappers are all CWindow -derived, so they can't be used with DDX. You need to do something like:
class CEditImpl : public CWindowImpl<CEditImpl, CEdit>
{ public: DECLARE_EMPTY_MSG_MAP() }; and use CEditImpl for your m_cEdit variable. Yes, it's a hassle.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated Aug 30!
|
|
|
|
|
You can try CContainedWindowT<cedit>.
Regards,
Lirong
|
|
|
|
|
Thanks for your answers Michael & Li, i know i need a CWindowImpl derived class to do the job, but what i mean is, i dont understand the phylosofy (pardon my spelling if wrong, english is not my native language) of the creators of WTL in this issue, because what DDX_CONTROL is supposed to do, its easier done -without- DDX_CONTROL!.
I find it "harder" (more time consuming) to have to write a class(even a small one) for every type of control i want to use, include the proper headers on my dialog class, add the ddx map entry, etc., than just declaring a member variable like CEdit m_MyEdit, or CListViewCtrl m_MyList, etc. and just attaching it via their Attach() method on my dialog´s OnInitDialog(), my point is ¿whats the design concept behind DDX_CONTROL? or in other words, ¿when do you actually use DDX_CONTROL because its easier to do so?
|
|
|
|
|
Ernesto D. wrote:
declaring a member variable like CEdit m_MyEdit, or CListViewCtrl m_MyList, etc. and just attaching it via their Attach() method on my dialog´s OnInitDialog(),
I would rather have a map in the header file, which is easy to find and edit, than calls to Attach(GetDlgItem(IDC_FOO)) over and over. The code to hook up all the controls at once with DDX is just one line, DoDataExchange(false); Using Attach() will work just as well, if that's the way you prefer.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated Aug 30!
|
|
|
|
|
We converted some of our small-size projects to WTL previously. Now we are skeptical putting more effort on WTL, as Microsoft now seems don't even want to improve MFC/ATL beside keep pushing (implicitly forcing...) .nut for C/C++, which in our view, would eventually kill C/C++ on Windows.
Anyone with any idea is WTL dead?
|
|
|
|
|
There was some talk of it going open-source, which would probably be enough to kill it effectively but Nenad is supposedly working on 7.1 or 8, partly to improve the support out of the box for VS.NET 2003, which otherwise requires some tweaks.
Steve S
|
|
|
|
|
Steve S wrote:
which otherwise requires some tweaks.
Some?
COM Out-proc server are easy to fix, but COM DLL's and WTL is a hassle. I ended up writing an adapter class for the COM Module stuff.
--
You still have your old friend Zoidberg. You all have Zoidberg!
|
|
|
|
|
Nenad has announced in the WTL ng that he'll be releasing a new version 'soon', which is fundamentally bug-fixes. I'm sure someone will announce it here when it happens.
Steve S
|
|
|
|
|
I make a com with atl ,and need an about dialog!
I want to Change Dialog Color,but the Control (for example .label icon) above
it is not transparent!how Can i do!
ZHANGYIFEI
|
|
|
|
|
I don't seem to have a problem exporting STL containers from a dll, but when i try to export a std::map that contains std::vector's, it somehow doesn't work. I've read the whole article provided by Mircosoft, but it does not discusses the problem that i'm having. Perhaps it has something to do with the fact that i've defined a map that contains others containers (nested structure).
Has anybody encountered the same problem and perhaps enlighten me? Many thanks in advance,
|
|
|
|
|
There's a known bug in Dinkumware's STL implementation (the one that comes with MSVC) which shows when attempting to export STL containers from a DLL. Check Dinkumware STL library fix section[^], and particularly the paragraph "Fix to <xtree>". Be careful when applying the fix (do a backup!)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i've just done some reading, and i don't think it is possible to export any STL container from a DLL, besides std::vector. This, ofcourse, is annoying as hell.
|
|
|
|
|
I was able to export all types of containers from a DLL. Of course I applied the patch Joaquin is talknig about and it works perfectly. BTW, the problems are fixed in VC 7.0.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
hmm...alright.....he i was wondering about VC7.0, thanks for clearing that up.
|
|
|
|
|
The VC6 implementation of std::map's is very annoying across DLL boundaries.
It uses some static members to keep track of sentinel values for the map. This means each DLL that uses a std::map will have different values, and causes the tree walking to much up because those values never match up.
To fix this problem for me, I used STLPort. http://www.stlport.org[^] It solved all my stl dll problems, and even got a bonus hash-map to use. Yay!
The other alternative (which I was using for a while) was to never pass stl containers around, and just try to have a plain interface wrapping them all. It wasn't much fun.
Phil
|
|
|
|
|
Hi, I want to be able to pass back an array of CString's from an ATL Server Web Service to a C# web Form's application.
Any ideas on how to do this?
e.g. here is example code on returning a single string (a BSTR):
namespace MyLabService
{
// all struct, enum, and typedefs for your webservice should go inside the namespace
// IMyLabService - web service interface declaration
//
[
uuid("911E5A7B-194B-4070-B080-36234B341D15"),
object
]
__interface IMyLabService
{
// HelloWorld is a sample ATL Server web service method. It shows how to
// declare a web service method and its in-parameters and out-parameters
[id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput);
};
// MyLabService - web service implementation
//
[
request_handler(name="Default", sdl="GenMyLabWSDL"),
soap_handler(
name="MyLabService",
namespace="urn:MyLabService",
protocol="soap"
)
]
class CMyLabService :
public IMyLabService
{
public:
// This is a sample web service method that shows how to use the
// soap_method attribute to expose a method as a web method
[ soap_method ]
HRESULT HelloWorld(/*[out, retval]*/ BSTR *bstrOutput)
{
CComBSTR bstrOut(L"Hello World");
*bstrOutput = bstrOut.Detach();
return S_OK;
}
}; // class CMyLabService
} // namespace MyLabService
Instead of:
[id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput);
I would like something like:
[id(1)] HRESULT HelloWorld([out, retval]vector<cstring> *Output);
I would really appreciate help on this one!!!!
Cheers,
Tony.
|
|
|
|
|
SAFEARRAY
Don't have a clue how they are handled in C# though. Sorry.
|
|
|
|
|
Use of SOAP 3 will save you a lot of time. Go MSDN and download the kit, look into the sample.
String array can be a comma separated, Recordset, XML format. SAFEARRAY is in fact not more than a struct, why must you stuck with it? Be more creative in solving the problem.
|
|
|
|
|
Is there a way to guarantee that the values inside a multimap are sorted in a certain way? I don't mean just sorting the keys, but values mapped to the same key also sorted by a functor (function object) or anything else? Even though I can retrieve the value_comp functor, I cannot set it because it's defined within the multimap class. This default value_comp just sorts the keys. What I really want is that equal_range returns iterators to sorted values according to my compare functor, but I couldn't find a way to accomplish this. The the values returned by the iterators aren't sorted in any special way that I can contro.
Thanks for any help,
rod
|
|
|
|
|
Well, you can have sort of what you're after by using multiset instead of multimap like the following: Suppose your multimap is originally defined as:
std::multimap<type_a,type_b> So, define a struct holding the two parts of the multimap :
struct pair_ab
{
type_a first;
type_b second;
bool operator<(const pair_ab& x)const
{
if(first<x.first)return true;
if(x.first<first)return false;
return second<x.second;
}
}; and replace your multimap with
std::multiset<pair_ab> Now, this multiset really behaves as a multimap on type_a with the added feature that elements with equivalent first members are further sorted by second . Please report back if this works. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It seems like like allocating memory for strings and returning a pointer to the caller would be very efficient.
However, it is considered to be a bad practice to allocate memory in a function and to expect the function caller to be responsible for memory deallocation. (This is how COM manages memory but that is another story.) Managing memory is a challenge. The various string classes in C++ have gone a long way towards resolving string memory problems in C++.
While string classes, such as stls std::basic_string are powerfull, it seems like there is a performance vs. safety trade-off. Sure, performance isn't as much of a concern as it use to be, but if we don't care about performance, we probably should be coding in Java, Perl, VB etc.
Now for some code:
std::basic_string<TCHAR>
SoapFault::GetSoapEnvelopeFault (bool IncludeDetail )
{
TCHAR* Soap = NULL;
TCHAR* SoapElements[3]; SoapElements[1] = NULL;
SoapElements[0] = SOAP_UPPER_ENVELOPE;
SoapElements[1] = this->BuildFaultXml(IncludeDetail);
SoapElements[2] = SOAP_LOWER_ENVELOPE;
Soap = TStrCat(Soap, SoapElements, SoapElements + 3);
delete (SoapElements[1]);
return Soap;
}
The last statement - return Soap - (note that SOAP is a raw TCHAR pointer) causes a new basic_string object to be constructed. A copy constructor is invoked and the contents of Soap are deep-copied to the new basic_string.
So here is the question - How do I return Soap, and construct a new basic_string class that shallow copies the Soap pointer? This would allow me to main my efficieny while retaining the safety of string class.
Ideas and opinions on the approach are welcome.
Links would also help.
thanks
|
|
|
|
|
I was under the impression that almost all implementations of basic_string use reference counted shared buffers internally, so that return is already, essentially, a shallow copy. I could be wrong, though (I have not examined the code myself).
- Mike
|
|
|
|
|
Thanks for the reply Mike,
I think CString reference counts but I don't think basic_string does.
I stepped through the copy-constructor with the debugger. The copy-ctor calls assign() and assign() calls copy().
The copy member function uses memcpy to deep-copy the characters.
I am sure that memcpy of array of characters probably is pretty quick.
I am thinking in terms of big multi-megabyte XML docs.
I have worked with CComBSTR in ATL. You can attach and detach raw BSTRs. When attached - the CComBSTR will manage the lifetime of the underlying BSTR. (The pointer approach). I would be cool if basic_string could do this somehow through the copy constructor.
|
|
|
|
|