Forgot your password?
Sign in with
Chapters and Sections
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View ASP.NET questions
View VB.NET questions
View SQL questions
All Message Boards...
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Design and Architecture
C / C++ / MFC
ATL / WTL / STL
Objective-C and Swift
Hardware & Devices
Hosting and Servers
Silverlight / WPF
Site Bugs / Suggestions
Spam and Abuse Watch
The Insider Newsletter
The Daily Build Newsletter
Most Valuable Professionals
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
General Indian Topics
What is 'CodeProject'?
Ask a Question
Bugs and Suggestions
Article Help Forum
Comments by Doc Lobster (Top 29 by date)
Reason for my vote of 3 \n To Hell with scopes I say. Any real programmer will gladly remember the glorious days of goto. Needless to say, I would have a talk with anyone within my scope that would dare to use a goto. Once, not twice.
Yes, I'm aware of COleDispatchException*. It is derived from CException, so catching CException will do the job.
Hi, thanks for your answer. LogString takes const CString& as parameter and the string is concatenated properly. Anyway, I found the solution, I'm calling Delete twice ...
Hello Pete, thank you for your answer. I tried replacing the standard tab control with the one from the Cinch v2 demo, however the exception stays the same.
I also tried to reproduce the problem with a simple (no tab header and content templates) code-behind demo project, which didn't show the exception. The idea that the view is destroyed on a tab change sounded a bit strange to me, so I added two non-bound radioboxes in a tab of that demo project. Their values are kept after tab switching away an back.
As I already spent quite some time on this, I'm now ready to avoid this by switching to another UI design. :(
I see the point now. You want to do the comparison through the base class only (BaseClass::equals) which would bring you in a typical double dispatcher situation. However, thats not possible to implement since the child class is a template and you cant have virtual method templates. In that case I would do mostly the same as in your solution with the only difference of using typeid/type_info.
Maybe its a misunderstanding and we are not trying to do the same thing. Anyway, both my code samples do not need base classes: The first one just looks at the composed type (if the composed type is the same the template parameter must be identical, too), the second one deducts the template parameter type in the has_same_parameter_type function.
As the tip is currently written, the ChildClass<t>::equals method would be generating at least a warning because of incomplete code paths. Also the static_cast following the comparison is not used or leading anywhere.
I think code samples (even if it is only a tip) should be somewhat consistent.
Reason for my vote of 5
Yep, that solution efficiently gets rid of any special case handling as any number now is a special case.
Also this is extremely portable, e.g. to french (99 = quatre-vingt-dix-neuf)
ah, its a limitation on the WaitHandle. Have a look at
it has its own waiting mechanism. Another solution may be to build your own thread-safe completion counter and waiting for that to reach 100.
I also found a good introduction to threading on http://www.albahari.com/threading/.
I think thats strange. There's no limit named by MSDN for queuing items into the ThreadPool. Also please note that an item queued into the thread pool is not necessarily started instantly, but placed into the internal queue (therefore the name). The number of threads executed concurrently is much lower and is said to be depending on your system. So what you actually built is a queue on the queue - if this is necessary there should be an object-oriented and reusable way of doing it.
For the beginners - you should include _why_ try / catch is bad practice in this case.
Reason for my vote of 5
Yep, thats what I do too. Having the var makes it even easier.
Just because one knows how to write generics, extension methods and lambda expressions is not reason enough to use it everywhere.
I suppose there is a certain degree of madness in most situations we have to cope with. Usual madness is okay by my standards, its something you can (or have to) hook off and get on with. It can be found anywhere, e.g. in a choleric co-worker. There is also unusual madness and sanity, I actually don't know which one of them is more threatening ;-)
My bad, I read the constructor execution path the wrong way around. Its a bit confusing to me that the simpler (shorter in means of arguments) constructors call the the ones being more complex.
I think there is a mistake in the refactored example. Originally every constructor would call DoStuff(), in the revised version only the constructor Something(string name, index) would do this.
Reason for my vote of 1
* malloc is C, not C++
* Bad usage of WideCharToMultiByte(...) - should be called twice, first time to evaluate output buffer size
* Assumes CString is wide-char
* std::string is usually host encoding (on windows some ansi cp), not UTF-8
* Missing exception handling may result in memory leaks
For such a common task as string conversion I expect a better solution
Reason for my vote of 1:
Sorry for being rude but this is an anti-tip if there is any:
double ConvertToDouble(CString strInput)
char * ch=new char;
1) Allocating ch is not necessary
2) static_cast is unsafe and uncalled for in this context. Your app will break as soon as compiled for unicode. Thats even independant of the static_cast.
3) strtod is C, not C++. CString is MFC/ATL.
Ah, I see. Its a C99 feature.
Why don't you just leave the optional macro parameter empty? RET_VAL_IF_NULL(p, ) does exactly what you want.
Unfortunatly not - I thought Substring(...) would cut the end of the string, not its start. See Daniels reply below
Hi Siavash, have you considered using a private enumeration and ToString() to get the property name strings?
Also you would have to use a magic number (4) so you still have the risk of setting the string range to an incorrect value (especially when using copy/paste). This isn't much better then the risk of a typo during entering the string.
Huh, I can see that. Unfortunately sometimes IT departments mistake their customer (which is the rest of the company) for a disease to be contained. They also simply might be upset because they were not involved in the first place. Best way to deal with it is to take it easy ... probably ;)
I like the metal umlaut in "önclick" ;-)
Have you experimented with xpath 2.0 functions? There are some allowing to convert item types, e.g. fn:string(0) or fn:number($rownr).
Hi Ataul, could you elaborate a bit on where you would use such a pattern and why it is better than passing the string pointer as normal parameter.
I also don't think CVHDDialogTmpl will work - its constructor initializes a member "str" which is not defined.
You can use the <pre> tag for C++ code highlighting if you add a lang attribute in the form <pre lang="C++"> ... </pre>.
This won't do for 0-characters in the input string as they would be recognized as string terminator. It probably would help providing the input buffer length as second parameter to the CString contructor. BTW, help in the msdn is provided for the CStringT template, not for CString itself.
Last Updated 1 Jan 1900
All Rights Reserved.