|
Jörgen Sigvardsson wrote:
For everything else (stuff that you've written with the use of CWindowImpl somewhere in your inheritance hierarchy), you just have to override OnFinalMessage(HWND) and delete this.
<br />
typedef CFrameWindowImpl<NoteWindow, ATL::CWindow, CMyWindowTraits> CMyFrameWindow;<br />
<br />
class NoteWindow : public CMyFrameWindow, <br />
publicCUpdateUI<NoteWindow>,<br />
public CMessageFilter, <br />
public CIdleHandler
that is my class inheritance. OnFinalMessage() causes an assert in WTL. that is the problem and it is by design, i need a way around it or i can't use WTL since it would cause memory leaks. these are supposed to be windows with you frequently open many of and close, and i don't want every object to be left in memory when the window is closed.
|
|
|
|
|
I assume you are using ATL3 (VC6). Have a look at this[^]. Basically you need to write your own window procedure to work around a bug in ATL3.
If you're using ATL7 there's something else going on which I'm unaware of. I successfully deleted this myself not too long ago.
--
Booohoo!
|
|
|
|
|
|
Dear All,
The sizeof keyword gives the amount of storage, in bytes, associated with a variable or a type.
Can any body suggest how to make our own function that operates like sizeof and gives the amount of storage in bytes.
Regards,
Rohit
|
|
|
|
|
|
What's wrong with:
template <typename T> size_t Sizeof() {
return sizeof T;
} For completeness I'd add
template <typename T> struct size_of : public std::generator<size_t> {
size_t operator()() {
return sizeof T;
}
}; and/or
template <typename T> struct size_of : public std::unary_function<size_t, T> {
size_t operator()(const T& v) {
return sizeof v;
}
};
--
Booohoo!
|
|
|
|
|
|
Hello All.
I'm have the next task:
I'm must to write an ActiveX component using C++ ATL.
This component must using SOAP client for working with WebService writed on C#.
For work with WebService from my component I must to use ASP.NET page SessionId.
This ID must be set as current SessionId(HINTERNET) handler for SOAP client.
But. C# SessionId it is string type. How I may convert C# SessionId to HINTERNET for using.
Thanks.
P.S. Sorry for my English.
|
|
|
|
|
Hi Dear...
I struck in a problem & I know you can help me..
I've a pro-merchant account in amazon..& I want to upload Inventory to amazon.. but getting problem..File Error..even from site upload...
Can you send me Execl file you used for that uploading...
+ if possible some coding snippet of uploading invenorty. I want to upload through coding.. send me at:
sumit_kapoor1980@hotmail.com
or chat with me at hotmail account or yahoo: sumit_kapoor1980@yahoo.com
I hope you will help me..
Thanks
Have a Nice Life..
Sumit Kapoor.
---Sumit Kapoor---
|
|
|
|
|
Is it just me, or is anyone else getting irritated by this...
Steve S
Developer for hire
|
|
|
|
|
it takes 1 week..still no solution..can you provide any hint...
Thanks...
---Sumit Kapoor---
|
|
|
|
|
Here's a hint.
Don't crosspost to every topic, it annoys people, and hence, makes them feel less inclined to help.
Steve S
Developer for hire
|
|
|
|
|
HI thanX...
I hate when no one help me... I'm trying from 1 week & posted in vc++ five time..no one reply...
so today..i posted to all..so that may be any other forum person know...
may be no know...
OK! Bye..sumit
---Sumit Kapoor---
|
|
|
|
|
hello,
I declare a class --- class CMainDlg :public CDialogImpl<cmaindlg>
{
enum {IDD = ...}
HWND m_hBtnApply;
......
}
the m_hBtnApply is the corresponding object of a resource IDC_APPLY in the resouce editor
I want to disable the IDC_APPLY in OnInitDialog message handler:
m_hBtnApply = GetDlgItem(IDC_APPLY);
::EnableWindow(m_hBtnApply,FALSE);
but it can reach the effects i wanted.while in MFC ,such code can do.
anybody can tell why?
mike shen
|
|
|
|
|
I have this explicit loop:
FileMap::iterator it;
for (it = outputFiles.begin(); it != outputFiles.end(); it++)
{
it->second->close();
}
where FileMap is a map<string,ofstream*>, so the loop is just going through all the stream pointers and calling close() on them
is it possible to implement this using for_each?, I tried this but got compiler errors:
for_each(outputFiles.begin(), outputFiles.end(), std::mem_fun<void, std::ofstream>(&std::ofstream::close));
|
|
|
|
|
map is a key/value type of container. Try a vector or something one dimensional.
Kuphryn
|
|
|
|
|
Yes, it is doable, but not using 'clean' STL design ideas. remember that the type of the element in the map is std::pair<string,ofstream*>, not just ofstream or ofstream*, so you need to compensate for that. The easiest way I can think of is to use lambda expressions (see boost::lambda for a comprehensive library).
Personally, I feel that lambda libraries are shakey ground at the moment. Most developers have enough trouble reading normal STL constructs without adding in strange things like '_1'and '_2' - but it depends on how comfortable with STL you and your co-workers are.
Just as an aside, are you sure that you really want to do this? Assuming that you dynamically creating the files why don't you rely upon the destructors to close the files for you - if this is the behavior that you want use boost::shared_ptr to keep a reference counter handle to the files, and when the map goes out of scope, all the files will be taken with it. The only other reason I can think that you would want to do this is to reuse the files, if you are doing this make sure that you test thoroughly Herb Sutter (the convenor of the C++ standards committee) documented some interesting 'features' (read: issues) of ofstream's after they have recycled in a recent issue of the C/C++ Users Journal.
After all that, if you're prepared to compromise on a 'dirty' rewrite for_each to work nicely with pairs, use the normal loop or try the following:
void closer(const std::pair<string,ofstream*>& toClose)
{
toClose.second->close();
}
for_each(outputFiles.begin(), outputFiles.end(), closer);
In this case I think your original loop really does make things a lot clearer than it would otherwise be.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks for that, that has cleared things up a lot for this STL newbie.
I am trying to make more use of the STL algorithms in my code, but in this case I will stick with the for loop, for clarity.
|
|
|
|
|
There is another thing you could add to Andrew's answer, without pulling in "weird lambda" stuff. This is what I'd do.
Add a function called select_second like this:
template <typename TPair>
struct select_second : public std::unary_function<TPair, typename TPair::second_type> {
result_type operator()(argument_type p) const {
return p.second;
}
};
then add a composer function like this:
template <typename F, typename G>
struct composed_fn : public std::unary_function<typename G::argument_type, typename F::result_type> {
const G& g;
const F& f;
composed_fn(const F& f_, const G& g_) : g(g_), f(f_) { }
result_type operator()(argument_type x) const {
return f(g(x));
}
};
template <typename F, typename G>
composed_fn<F, G> compose(const F& f, const G& g) {
return composed_fn<F, G>(f, g);
} Then you ought to be able to do something like:
for_each(outputFiles.begin(), outputFiles.end(), compose(std::mem_fun(&std::ofstream::close), select_second<FileMap::value_type>())); I'm not sure if functional composition is possible in boost without the use of the "obscure" lambda library. If it is, please use boost instead. It's good and solid code. However, I've used this code myself for a while, and I've found it to be useful. It's easy to follow and understand if you have a grasp of templates and functors. f(g(x)) shouldn't be a surprise to anyone, it's basic high school mathematics.
--
Booohoo!
|
|
|
|
|
Thanks Jörgen, answers like this are why I love CodeProject, fully deserving of a five.
Time to go back and fix some of that old code...
Boost::Compose[^] Has been deprecated in favour of bind and lambda btw
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks for your kind words.
Real soon now, I will be ending a java project (at least my involvement in it), and go straight back to C++. I can't wait.
I have a bunch of header files with code for dealing with composition. With a bit of luck, I'll see if I can gather enough strength and will to write an article about it later on. Sure, there's always boost, but I figure I can show the concepts of functional composition if I used my own code. I think just the awareness of these tricks makes STL a lot easier and more enjoyable to work with.
--
Booohoo!
|
|
|
|
|
Hello all. Tell me please can I get the http session which was created by ASP.NET page from my ATL ActiveX component and work with it? Thanks.
|
|
|
|
|
Alright,
I've taken an existing VC6 C++ COM dll which uses MFC libraries, converted it to VC 7 and added the ATL COM+ class. It compiles fine. However when I try to drag and drop it into COM+, I see nothing visually show up. I looked at the registry and it does register the ATL dll. I also took another ATL Dll, downloaded it's source code, and recompiled. Then dragged and dropped it into COM+ and the classes and interfaces show up so this to me means I don't have any issues as far as the present of the necessary dlls. Specifically atl.dll.
The ATL dll that I used as an example that works is much smaller than the one I'm creating and it doesn't use the MFC library but from everything I've read that shouldn't make a difference.
One final note: I did add the ATL DLL manually instead of using drap-n-drop and it displays the class but no interfaces are present.
Paul
|
|
|
|
|
Hi All
Is it possible to develop a COM server as a/service which would start when a client instantiates an object of it?
I know this is possible in theory, but I've tried doing it, by creating a Service using ATL COM Wizard and then adding an ATL Object.
From the client, I tried to instantiate an object of this exposed interface. But the service does not start up and the pointer returned to me in the client is NULL.
Can anyone help me provide pointers?
Thanks in advance,
Cheers
Raja
|
|
|
|
|