|
Hi all
I get the Configuration for my application from the Registry. If i write the hostname-field(CEdit) into the Registry, only a few chars were be saved in the Registry. If i read the Registry-entry(eg. hostname), only the first letter were be printed. Do someone have an idea, what the problem is or better what i can do?
I'm really stumped...
and sorry for my english!
hopefull
simon
|
|
|
|
|
Sounds like you're reading UNICODE data but interpreting it as an ANSI string.
Steve
|
|
|
|
|
Before I set the CEdit field with the value, I put the value in a CString. Isn't CString an UNICODE string?
-- modified at 4:01 Tuesday 21st March, 2006
|
|
|
|
|
Yeah, a CString "knows" whether to be UNICODE or ANSI. Can you show the reading a writing code?
Steve
|
|
|
|
|
Ok, here is a link to my .cpp file: www.planetsite.ch/ccode/settings.cpp
-- modified at 8:40 Tuesday 21st March, 2006
- corrected the url
|
|
|
|
|
Ok, I really need to see settings.h and Registry.h.
Steve
|
|
|
|
|
I can't see what (if anything) you're doing wrong. I suspect the problem might be in the CRegistry class.
Steve
|
|
|
|
|
Hello Community,
i have a litle problem do make a file with unicode characters, ANSI is not a problem,
does any one have a example for this, or tut?
thanx
break;
|
|
|
|
|
Hi there,
*Unicode file* means? An app that is aware of unicode? For that, you need to add the following to your stdafx.h
#define _UNICODE
#define UNICODE
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Create the file with ::CreateFile , write the unicode text to the file with ::WriteFile and close it up with ::CloseHandle . Exactly the same as with ANSI characters, with the exception of wider characters, so that if you have
std::wstring text(L"Unicode text"); then write the data stream
text.data() which has the byte size
text.size() * sizeof(wchar_t) Was that what you meant?
Of course, there are abstractions that makes it easier to work with the Win32 file APIs. But grok the above and be a happier man.
--
The Blog: Bits and Pieces
|
|
|
|
|
Hello,
thax for answers, i try to make it!
regards
break;
|
|
|
|
|
Hi all,
I have an MDI application with multiple views (CScrollView, CFormView). Lets say there are five views opened (CScrollView -3, CFormView -2). There is a member "Child_Id" in the CScrollView class.
At one point of time - in the application class, I'd like to update (repaint) a CScrollView object with a given "Child_Id".
Give your hands please...
Thanks in advance,
Sarvan AL
|
|
|
|
|
You can take a look at the following functions...
CDocument::GetFirstViewPosition();
CDocument::GetNextView();
CMultiDocTemplate::GetFirstDocPosition();
CMultiDocTemplate::GetNextDoc();
Nibu thomas
Software Developer
|
|
|
|
|
I have a CString object loaded with a string like "This is the first section$This is the second section$This is the end" so each section separated by '$'. I try to load the second section as csAnsprech = csComboBoxText.Mid( csComboBoxText.Find( '$') +1, csComboBoxText.ReverseFind( '$')); but this retrieves the second and third section, nut just the second one. What´s wrong here ?
|
|
|
|
|
int nPos = csComboBoxText.Find( '$') + 1;
csAnsprech = csComboBoxText.Mid( nPos , csComboBoxText.GetLength()- csComboBoxText.Find( '$',nPos ));
nave
|
|
|
|
|
Hello RadioOpa,
try this:
<br />
int i =0;<br />
while(i < csComboBoxText.GetLength())<br />
{<br />
if(csComboBoxText.GetAt(i) == '$')
{<br />
i++;
while(csComboBoxText.GetAt(i) != '$')
{<br />
csAnsprech += csComboBoxText.GetAt(i);<br />
i++;
}<br />
}<br />
i++;
}<br />
i hope that helps you!
regards
break;
P.S. that sample from nave ist very good, i want just to show you another way without Find-Functions to extract a part of string
-- modified at 2:55 Tuesday 21st March, 2006
|
|
|
|
|
Many thanks, both ways solving the problem are excellent.
I changed code as follows:
iFirstSection = csComboBoxText.Find( '$'); // Find first '$'
iSecondSection = csComboBoxText.Find( '$', iFirstSection +1); // Find second '$'
csFirma = csComboBoxText.Mid( 0, iFirstSection); // Get first string section
csFirma.TrimRight( ' ');
csOrt = csComboBoxText.Mid( iFirstSection +1, iSecondSection - iFirstSection); // Get second
csOrt.TrimRight( ' ');
csFirmaID = csComboBoxText.Mid( iSecondSection +1); // Get last section
|
|
|
|
|
|
Hi all
I have a char array
char codenew[12];
codenew[0]='\0';
How to convert it into a CString ?
Any help plz ?
redindian
|
|
|
|
|
char codenew[12];
strcpy(codenew,"Blah");
CString TempString = codenew;
|
|
|
|
|
hi
Thanks
Now i am facing another problem
char autocode[12];
stycpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(char*)(csBuffer.GetBuffer(csBuffer.GetLength()))))
{
csBuffer.ReleaseBuffer();
return TRUE;
}
Now , at csBuffer.ReleaseBuffer() ..it crashes ..
I dont understand why ...
I feel strcmp still holds the memory returned by csBuffer.GetBuffer right ?
can u help me solve it ?
redindian
|
|
|
|
|
Why don't you just do this?
char autocode[12];
strcpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(LPCTSTR)csBuffer)) return TRUE;
A CString is freed when it goes out of scope so you (normally) don't have to.
OT:
Why should it return TRUE for a difference between autocode and csBuffer?
|
|
|
|
|
dharani wrote: char autocode[12];
stycpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(char*)(csBuffer.GetBuffer(csBuffer.GetLength()))))
{
csBuffer.ReleaseBuffer();
return TRUE;
}
You are going a long, long way just to compare strings. Note that you are not doing anything specific to CString s, so it is a waste to use one. But since you have one, use its Compare(...) method:
CString csBuffer = _T( "1234" );
if( !csBuffer.Compare( _T( "1234" ) ) )
{
}
else
{
}
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Have you tried this
char c[10] = "My Array";
CString str;
str.Format("%s",c);
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
as Cedric explained with a code sample, the CString class provides an operator = (const TCHAR*) which allows you to assign directly a CString with a char*...
char* codenew = "hello";
CString str = codenew;
|
|
|
|