|
Well,I think I found it. :
string strfile=finder.GetFilePath();
ifstream file(strfile.c_str());
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Yup - that will do it. If you had a CString, then you'd use GetBuffer & ReleaseBuffer.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Whether it's the cause of the problem or not, i don't know, but this line is wrong:
CString str1=(CString )(list1);
you can't cast list1, which is a char* to CString.
However, CString has an operator designed for the job:
CString str1 = (LPCSTR) list1;
jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon Hulatt wrote:
CString str1 = (LPCSTR) list1;
hmmmm,thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Hi,
I wrote a little tool for our current project here that automatically sends off messages to selected users using NetMessageBufferSend(). It works okay
when I sent off messages from my Win2000 system...every recipient gets the message. What's strange, the tool doesn't work on NT5.0 (SP6) machines -- I always get "NERR_NameNotFound" errors. I tried different ways to convert the relevant strings to UNICODE, but none of these does the trick:
(1)
#define MESGLEN 50000
WCHAR awcToName[MESGLEN*2];
ZeroMemory( awcToName, sizeof(WCHAR)*MESGLEN);
MultiByteToWideChar( CP_ACP, 0, strEmpf, strEmpf.GetLength(), awcToName, MESGLEN);
(2)
wchar_t name[256];
mbstowcs(name,strEmpf,256);
name[256 - 1] = L'\0';
(3)
_towchar(strEmpf) from TConvert.h written by Zoran M.Todorovic
Anyway, launching the usual "net send ..." from a CMD window works on the NT machines, so all required services, etc. seem to be up and running, so I believe it's a string converting problem, although I cannot see where the error might be, since any of the routines (1) - (3) mentioned above work perfectly under W2K.
Any suggestions anyone? I'd really appreciate your help with this.
Thanx in advance
--j
-----------------------------------------
There are three kinds of people:
Those who can count and those who cannot.
|
|
|
|
|
Helo everyone
I'm trying to develop aplication that can capture still images from TV live source.
theese are my inputs...
I'm using DirectShow filters (DirectX 8.1 SDK)
Capture device is
ATI Rage Theater Video Capture chip
My still cap graph contains all needed upstream filters
up to Capture BaseFilter
I rendered preview pin to see Live Preview (works fine), then
I rendered capture pin to get video file (works fine),
I rendered VBI / CC pin (works fine).
Here comes the pain :
I use SampleGrabber filter to get still image
as used in StillCap SDK example.
I add Sample Grabber filter to graph (its connected to capture pin)
and render SampleGrabbers output pin, no errors returned,
but when I try run this still cap graph it returns
"A device atached to system is not funcionating"
Same error ocured in StillCap example, but when I use ATI TV program
It captures still images with no problem.
I've forced this problem for month , so any suggestions are very welcomed.
|
|
|
|
|
There must be a good reason why
operator const E*() const;<code><br />
isn't a member of basic_string. Has there been any discussions regarding this on this message board? I really can't come up with a good example where this might be harmful. Maybe just avoiding implicit type conversion is the stand alone reason? Could anyone give an example why this operator is omitted? I'm sure there is a good reason, just can't figure out why. :confused:
|
|
|
|
|
...or maybe I'm just plain stupid. I can't even get the simple HTML tags right
|
|
|
|
|
The main reason why operator const E*() const was banned out of the standard is simply that too many people were againt them. There's a general suspicion about implicit conversions as the can make call to overload functions ambiguous and make the code less clear (allegedly). But the subject is somewhat controversial, and not everybody agrees with the resolution taken by the standard commitee. The example against operator const E*() const that I find most convincing is this: suppose the conversion operator actually exists, then the following piece of code works just fine:
void f(const char *)
{
...
}
...
string s1="Code";
string s2="Project";
f(s1+s2); But the following snippet will fail, although it seems an innocent version of the former:
string s1="Code";
string s2="Project";
const char *p=s1+s2;
f(p); The reason why this fails is that p is no longer valid because the temporary (s1+s2) according to the standard rules might have been deleted when the call to f comes. Introducing c_str does not prevent this problem, but at least make you think twice about it ((s1+s2).c_str() is an eye-catching sentence, isn't it.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
The main reason why operator const E*() const was banned out of the standard is simply that too many people were againt them
Totally agree with them, but in the beginning I was totally against, until I discovered the reasons for this behaviour. Of course as you pinpoint, there are a quite few people that strongly disagree with this, but after all even the standard cannot please all of us.
Although this guys are cleaver , sometimes they just make nonsense decisions like the vector<bool> specialization returning a proxy object , of course this is just plain broken and will be fixed in next one, but this is a sample that this guys sometimes doesn't put the necessary thought on some things.Unfortunately even Stroustroup is against the ideia of incorporating in the C++ core proper multithreading support to do properly multithreading programming(and portable too). They could use policies to provide true thread safe capabilities to stl,not a difficult situation to deal with, and they also could provide true thread safe lazy initializion to c++, for instance in the case of the singleton pattern ..., but no, they don't want that ... lazy guys, and they are suprised that the guys on comp.lang.threads don't like them at all !!!
Joaquín M López Muñoz wrote:
(s1+s2).c_str() is an eye-catching sentence, isn't it
Definitely is ...
Cheers,
Joao Vaz
|
|
|
|
|
(Ok, RAMBLE WARNING!!!)
I hope they never introduce thread safety in the core STL objects such as vector. In my experience, my thread safety requirements extend far beyond just a single instance of a map or vector. Thus, having private locking for these objects does little good.
Then again, my opinion on adding every little thing into the standard is well know.
I was thinking about this stuff this morning and realized something.
1. I don't agree with shops that require that you use 100% standard objects. I think that is counter productive. You just can't have one solution that solves all problems. IMHO, as we get more and more specialized with elements we are adding to the standard, this will become more and more evident.
2. I don't agree with the idea that standard equates to portable. I have had enough years implementing standards to know that there is a huge gap between the ideal standard and that implemented standard.
People might not agree with me, but that isn't the point. If you assume these two points to be true, I think is would be easier to understand why I don't want a lot of junk added to the standard. If feel that people can still get the portability they need from well supported and designed initiatives like BOOST. I really don't see what there is to gain by adding it into the standard. If condition variables get added to the standard, MS isn't going to suddenly decide to add a CV primitive to the XP, W2K, NT4, ME, and 9x. They will just use one of the composite implementations. So what do we really gain? A red rubber stamp that says "this is now standard". Beyond that, what are the real tangible benefits?
If a solution is already portable, why does it suddenly become even more portable when it has the stamp of the standard?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
WARNING: LONG RANT HERE TOO
Tim Smith wrote:
I hope they never introduce thread safety in the core STL objects such as vector. In my experience, my thread safety requirements extend far beyond just a single instance of a map or vector. Thus, having private locking for these objects does little good.
Hum, you perhaps misinterpreted what I said, I will try to better explain this:
If you readed Modern C++ Design , the 1st chapter deals with the concept of policy classes, this concept is seemed with the strategy pattern, for instance
the policy class :
template<class ThreadModel = ThreadSafeRead>
class CThreadingModel
{
lock();
...
}
The vector instead of :
template <class Type,class Allocator = allocator<Type>> class Vector;
would be:
template <
class Type,
class Allocator = allocator<Type>
class ThreadModelSafety=CThreadingModel
>
Transparent, by default the normal STL behaviour, explicity full MT semantics or other hybrid thread model
Of course this lead to problems mixing classes with different thread models, but hey this is just a thought , besides it's a normal problem when mixing classes with different strategies ...
Tim Smith wrote:
I don't agree with the idea that standard equates to portable. I have had enough years implementing standards to know that there is a huge gap between the ideal standard and that implemented standard.
Of course is a very difficult task, not impossible ... but even so I liked the threading option to be added to the c++ core, not only the stl .
Tim Smith wrote:
If feel that people can still get the portability they need from well supported and designed initiatives like BOOST
A very nice initiative indeed
Tim Smith wrote:
. If condition variables get added to the standard, MS isn't going to suddenly decide to add a CV primitive to the XP, W2K, NT4, ME, and 9x.
Hey Tim, I'm not talking about CVS here , I known that you're still shaken by the not in the very past long arguments held here at CP
But I'll warning you after I'm finally conclude my ICMP protocol article with c# , I'll write a article with a portable thread pool implementation, and suprise, it will have CVs, so I'm expect to be badly beaten by you respecting this and the possible quirks that it may have
Tim Smith wrote:
If a solution is already portable, why does it suddenly become even more portable when it has the stamp of the standard?
Not more portable, only more standard
Cheers,
Joao Vaz
|
|
|
|
|
I strongly disagree with this approach for STL thread safety. It is consistent and would work, but IMHO almost never will suit any programmer's need. Consider for example a for_each operation performed on a std::vector : as for_each only sees the vector thru iterators, this implies that the operation locks and unlocks the vector every time it accesses it. In many occasions one will need that the entire for_each operation is done within a single lock section. Defining appropriate interfaces to achieve this in a generic manner is probably impossible. In more contrived examples, one seeks atomicity for several such operations executed in sequence, and now things become much more complicated than the simpler approach of doing the locking separately. In a nutshell: "atomicity" is too program-specific a concept to be reduced to access-level locking.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Consider for example a for_each operation performed on a std::vector: as for_each only sees the vector thru iterators, this implies that the operation locks and unlocks the vector every time it accesses it. In many occasions one will need that the entire for_each operation is done within a single lock section
Of course with full mt semantics this will lock every operation, but imagine two threads writing to the same vector, and the vector doesn't care about the order in wich threads write, this will improve concurrency , than serializing all the insertions ...
If you want the transversal of vector to be more quickly, you would define the normal thread safe model that most STL implementations use, so using for_each will increase the speed of the loop.
So when you define your vector you must think carefully if this vector will be used much more times in a read scenario than a write scenario or vice-versa.
You could use also template operator= to convert on the fly the vector with threadmodel MT to be used with the normal Thread Read Safe model(possibly very costly or not advisable at all), or you could use the Adaptor Pattern to adapt the class to a different thread model ...
Cheers,
Joao Vaz
|
|
|
|
|
I see what you are getting at, but for an experiensed programmer, both versions (p=s1+s2 and p=(s1+s2).c_str()) should be eye-catching. Most programmers I know uses prefixed variable names to avoid these kind of pit falls. While for an unexperiensed programmer, probably neither is. So I really don't see who the standard commitee is targeting when omitting the operator.
|
|
|
|
|
I'm looking for a tabctrl in which I can add views.
Can somebody help me.
thanx in advance.
CYCOSI
|
|
|
|
|
Maybe it helps.:
http://www.codeproject.com/tabctrl
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
How do you mean ? What's wrong with the one in MFC ? What do you want it to do ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I have created 6 ListViews.
They are working good.
I now want to put them into a tabctrl.
Is it possible with the one in mfc.
If yes, how to do that.
Thanx
|
|
|
|
|
Easy - create six tabs, then create the six tab views as children of the tab control. Then you need to call ShowWindow(SW_SHOW) and ShowWindow(SW_HIDE) on them as the tab selection changes.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Check KB article Q161886.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I use CFileFind and GetLenght() to get size of file.It returns it in BYTE.Now I want to use FILE structure to write or read file,I have to give lenght to this structure and I want to give it in "char".How can I do it?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
CFile::GetLength returns an ULONGLONG , not a BYTE . What do you exactly mean?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
CFile::GetLength returns an ULONGLONG, not a BYTE. What do you exactly mean?
Oh,yes.As I said I have FILE structure and I wanna read all its data charachter by character.I want to give the length of the character I want to read from file to the FILE structure.(which I get it with GetLength() ) Now it gives me ULONGLONG,and I have to give it to FILE in number of charachter.Is it clear or I explain it again?
Thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Is it clear or I explain it again?
Excuse my poor understanding, but I still don't get it. What does "give it to FILE" mean? FILE is an opaque structure you're not supposed to manipulate directly.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|