|
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;
|
|
|
|
|
My code is followed, it's good to run in a general WinApp,but in a windows service,it doesn't work. Does anybody give me a hand?
void CLoadDlg::StartUpFederate(CString federatePath,CString sCommandLine)
{
char cCommandLine[MAX_PATH];
PROCESS_INFORMATION pi;
STARTUPINFO si;
memset(&si,0,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
char CurrentDir[MAX_PATH];
//GetCurrentDirectory
GetCurrentDirectory(MAX_PATH,CurrentDir);
//SetCurrentDirectory
SetCurrentDirectory(federatePath);
::strcpy(cCommandLine, sCommandLine);
SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;//TRUE;
sa.lpSecurityDescriptor = &sd;
BOOL ret = CreateProcess(NULL, // pointer to name of executable module
cCommandLine, // pointer to command line string
NULL, //&sa,//// process security attributes
NULL,//&sa,// // primary thread security attributes
FALSE,//TRUE, //FALSE,// handle inheritance flag
0, //CREATE_NEW_CONSOLE// creation flags //HIGH_PRIORITY_CLASS
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi); // pointer to PROCESS_INFORMATION
//SetCurrentDirectory
SetCurrentDirectory(CurrentDir);
}
|
|
|
|
|
There is many url protocols such as "rtsp" "mms" "http" "ftp" "svn" and so on.
Now, I want to establish my own protocol. For example:"mypro"
How to do it?
Thanks.
|
|
|
|
|
Luckily, I found the answer at "Registering an Application to a URL Protocol" of MSDN.
|
|
|
|
|
hello frds ,
i stuck at the point of filling pixels in bitmap file....
Problem:
i have to genarate a .bmp file thas why i write a BITMAPFILEHEADER and BITMAPINFOHEADER structure in file.
now i face difficult to fill colors in that file.
i am not getting what is palatte and rgb quad.
I directly put the value of rgbquad in file like
fwrite(&rquad,sizeof(rquad),1,image);
it doent work!!!
reply
thanks in advance !!
Rahul here
|
|
|
|
|
Hi rahul.shendurnikar,
Do you want to create bitmap and draw color on the bitmap
|
|
|
|
|
hello frds ,
i stuck at the point of filling pixels in bitmap file....
Problem:
i have to genarate a .bmp file thas why i write a BITMAPFILEHEADER and BITMAPINFOHEADER structure in file.
now i face difficult to fill colors in that file.
i am not getting what is palatte and rgb quad.
I directly put the value of rgbquad in file like
fwrite(&rquad,sizeof(rquad),1,image);
it doent work!!!
reply
thanks in advance !!
Rahul here
|
|
|
|
|
What does __RPC_FAR do?
typedef /* [unique] */ IDispatch __RPC_FAR *LPDISPATCH;
What does this signify?
Thanks for helping!
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Save My Soul - (SMS) wrote: What does __RPC_FAR do?
typedef /* [unique] */ IDispatch __RPC_FAR *LPDISPATCH;
What does this signify?
16 bit environments used to have near and far pointers, and __RPC_FAR used to indicate a far pointer. It is provided for compatibility reasons, it is defined as nothing.
Nibu thomas
Software Developer
|
|
|
|
|
Hi all,
How can I change the font of the dialog dynamically. I have tried SetFont from OnInitDialog() function.But it dosen't work.
Please help me
Thanks in advance
Naveen.R
nave
|
|
|
|