|
I'm not sure if this will work, but have you tried simply setting the LPTSTR equal to the CString? I think CString has an LPTSTR operator if memory serves...
-Kmaz
|
|
|
|
|
CString is not able to be assigned with LPTSTR,
LPTSTR lpszString = filename;
gives error
error C2440: 'initializing' : cannot convert from 'class CString' to 'unsigned short *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
|
|
|
|
|
CString has an LPCTSTR operator, so you can pass a CString object to any function that requires a LPCTSTR
fptr = fopen(m_fileName, _T("r")) CString::GetBuffer() returns a LPTSTR, not a LPCTSTR.
LPTSTR is a char*
LPCTSTR is a const char*
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
m_fileName is CEdit type. Also i hv to collect string value from CstringArray like this..
CStringArray* aXMLfiles;
CString filename;
int mlen = aXMLfiles->GetSize();
// write all the XML files
for(j=0;j<mlen;j++)
{
filename="aXMLfiles-">GetAt(j);
LPTCSTR lpszString = filename;
fptr = fopen( lpszString, "r" );
////do something////
}
still i get error.
|
|
|
|
|
You can take away the extra assignment, this is enough:
fopen( filename, "r" );
or this:
fopen( ( LPCTSTR ) filename, "r" );
If not, your problem lies elswhere, and you might want to post some more code.
|
|
|
|
|
still problem continues.I put the code for ur ref.
CStringArray* aXMLfiles;
int mlen,j;
CString filename;
FILE *fptr;
aXMLfiles = GetFileNames("*.XML"); /// This function retrives me all XML files..
mlen = aXMLfiles->GetSize();
for(j=0;j<mlen;j++)
{
="" filename="aXMLfiles-">GetAt(j);
fptr = fopen( ( LPCTSTR ) filename, "r" );
if (fptr != NULL){
// do something }
}
fopen' : cannot convert parameter 1 from 'class CString' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called.
|
|
|
|
|
As CString has a user-defined operator LPCTSTR , the "or the operator cannot be called"-part of the error message seems to be the interesting part. What is the error number (CXXXX) you get?
|
|
|
|
|
Are you using Unicode? The complaint about "unsigned short*" looks like you are trying to feed wide characters to a function that understands only 8-bit chars.
|
|
|
|
|
This is why i stopped using CString.
It's an all or nothing proposition.
If you compile for UNICODE then it wraps an array of wchar_t (unsigned short).
If you compile for ANSI then it wraps an array of char.
You can't cast between the two, you must convert.
Use wcstombs to go from a wchar_t to char.
Use mbstowcs to go from a char to wchar_t.
[EDIT]
Actually what you should do if using CString is go the whole way and use all the _t funtion versions. e.g. _tfopen() will work with a CString regardless of it being UNICODE or ANSI. Most functions that take a char* have a _t*() version. Check the MSDN doc's.
[/EDIT]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I want to make a dialog popup like a toolbox, but be a resizable dialog with controls i want on it. I've seen it in some other applications and I would like to add it to one of mine. Any links/ideas/suggestions would be appreciated.
-Kmaz
|
|
|
|
|
You want a resizable, modeless dialog. It's not different from a normal dialog, but you select resizable border from the styles in the resource editor, and call Create instead of DoModal . Add a member of the dialog class to the parent class, call Create as soon as possible (after the parent window is created, this depends on the kind of window), and then call ShowWindow to show/hide the toolbox.
|
|
|
|
|
I can't believe i didnt think of that...I'm an idiot
|
|
|
|
|
No, you would have been... not an idiot, but slightly silly if you hadn't asked the question
|
|
|
|
|
Hello!
I am trying to make a ActiveX in the Visual Studio.NET 2003 IDE and I want the ActiveX to use MFC version 4.2 ; can it be done ? and how ?
|
|
|
|
|
I'm trying to get automation for Outlook working. Well, all the examples I read here on codeproject and find elsewhere 'round the internet involve either a #import of msoutl.olb and mso.dll or having class wizard handle them automatically. Thing is, I can't find ANY of these files anywhere. I've looked on my computer, my dad's, my brother's... none of them have said files either. I thought they were supposed to be installed with Outlook Express! I've found msoutl.olb floating around the net in a zip file, but mso.dll I haven't. So, if anybody could tell me where to find these files, I would be most appreciative.
augy
|
|
|
|
|
Outlook and Outlook Express are totally different beasts.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Ahhhh, so the files come with outlook but not outlook express?
Bastards.
Thanks for the reply.
|
|
|
|
|
the_augy wrote:
Ahhhh, so the files come with outlook but not outlook express?
Sadly, Outlook Express doesn't support an object automation model. I've always thought this was a shame but I guss Microsoft had their reasons. (Probably down to all the security issues that the original Outlook model caused)
Michael
CP Blog [^]
|
|
|
|
|
I'd like to change the font for my CEditView in my MFC Doc/view application. I am using VC++ 6.
Anybody know how?
Thanks, David.
|
|
|
|
|
Use SetFont() . Just be sure that the font you are using has the same life span as the view.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Works perfect! Thanks a lot!
David
|
|
|
|
|
"MFC AppWizard(exe)" and "Win32 Application",
"MFC AppWizard(dll)" and "Win32 Dynamic-link Library",
"Database Project" and "New Database Wizard" and "Extended Stored Proc Wizard"
when i create a new project?
thanks for your help!
|
|
|
|
|
I don't have VC6 open in front of me, but if memory serves, the only difference is that the MFC AppWizard takes you through a bunch of extra hooey (that is, steps in the wizard) and then generates a large majority of the code for you, whereas a strait win32 application, well, doesn't: it just gives you an empty project.
augs
|
|
|
|
|
An MFC project - of course - also includes MFC
|
|
|
|
|
hi,
how can i costumize the tab order in the Dialog window editor?
|
|
|
|