|
i wrote the text into the file using
CStdioFile f1;
if( f1.Open( pFileName, CFile::modeCreate
| CFile::modeWrite | CFile::typeText ) )
{
f1.WriteString(_T(szSampleText));
f1.Close();
}
i need to read the same string.
please help me,
if there is any method to read the string?
|
|
|
|
|
kumaraghuru wrote: CStdioFile f1;
if( f1.Open( pFileName, CFile::modeCreate
| CFile::modeWrite | CFile::typeText ) )
{
f1.WriteString(_T(szSampleText));
f1.Close();
}
how about doing the same thing :
CStdioFile f1;
if (f1.Open(pFileName,CFile::modeRead))
{
f1.ReadString(szSampleText));
f1.Close();
}
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
i have tried giving the same thing as specified by Mr. YaronNir
but, if the szSampleText array is printed, it returns some kind of irrelevant value.
is any type conversions are needed to fit this one.
|
|
|
|
|
show me the exact code including the definition of the szSampleText string....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
i tried to give the same thing as specified by Mr. YaronNir
but the string it returns is in some other irrelevant form.
are there any type conversions or any other method to get the original string in a correct format
|
|
|
|
|
sir, the text file was in unicode sir
Kumaraghuru
|
|
|
|
|
CStdioFile reads/writes Multi-Byte ANSI text to the file even if the source code is compiled as UNICODE.
Visual Studio 2005 supports UNICODE/UTF-8 files with the buffered I/O series of CRT functions (fopen, fwrite, etc.), many which are used by CStdioFile. However, CStdioFile does not directly support these (due to how it opens files--it doesn't actually use fopen().)
Another option is to use the class from this article: http://www.codeproject.com/file/stdiofileex.asp[^]
I have not used nor tested this class, but I've looked at it and it seems to do what you want.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
This will load a text file formatted in ANSI or UNICODE. It's meant to be used in a Doc/View app but you may find it useful to build on. It is in no way complete and it's kinda messy but it gets the data read in nonetheless...
// Assumes compiling for MBCS.
CString m_DataString // Member of document object so view can get to data
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
ar.Flush(); // Need to get rid of Mr. Hanky before
// calling CArchive::GetFile(). Hidee Ho!
CString sResult="";
CString sFileData="";
int nFlags=IS_TEXT_UNICODE_SIGNATURE;
const CFile * file=ar.GetFile(); // Get a const file pointer from CArchive
int nLength=file->GetLength();
LPSTR pBuffer=sFileData.GetBuffer(nLength+2); // Need 2 bytes for unicode
// null terminator, just in case
ar.Read(pBuffer,nLength); // Read the data in raw
// Append a unicode null terminator to prevent
// one of lifes little oopsees...Don't assume anything
pBuffer[nLength]='\0';
pBuffer[nLength+1]='\0';
nLength+=2; // Adjust 2 bytes for unicode null terminator
if (::IsTextUnicode(pBuffer,nLength,&nFlags)) { // Unicode encoded file
// Get the required buffer size for multibyte buffer
int nResultLength=::WideCharToMultiByte(CP_ACP,0,(PWSTR)pBuffer,-1,
NULL,0,NULL,NULL);
// Do the conversion and save it in member variable for when
// the view is ready to load
::WideCharToMultiByte(CP_ACP,0,(PWSTR)pBuffer,-1,
m_DataString.GetBuffer(nResultLength),
nResultLength,NULL,NULL);
m_DataString.ReleaseBuffer();
sFileData.ReleaseBuffer(); // pBuffer no longer valid
m_DataString.Delete(0,1); // Remove what used to be the
// Unicode byte-order mark 0xFEFF
} else { // File not encoded
sFileData.ReleaseBuffer(); // pBuffer no longer valid
m_DataString=sFileData; // Save it in member variable for when
// the view is ready to load
}
}
-- modified at 11:07 Sunday 30th April, 2006
|
|
|
|
|
I have created a project not supporting activeX controls,but now i must
use activex control,which item should i update in .vcproj file to make the project supportting active controls? Or i have to create a new project and inport all files ?
|
|
|
|
|
when you mark the check box in the wizard to support ActiveX controls,
a method is being added to your InitInstance function. the method is called AfxEnableControlContainer
just add it at the begining of your init instance function.
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
hi,
i need a lot of help with this. i am trying to set and get the text in a RichEdit20W of another application. i know the window title and nothing else. i'm pretty sure this is possible (anything is?) but i've tryed a lot of things but haven't had any luck.
i don't need the whole answer (although it would be nice ), im just looking for a point in the right direction.
thanks in advance.
|
|
|
|
|
|
use SPY++ application (shipped with Visual Studio) to determine the relation ship between the main window and the rich edit. meaning is it a child of a child or a child of a child of a child.
once you've figured it out, use GetWindow() method with GW_CHILD parameter, until you've got the proper HWND that points to the rich edit control....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Oh yeah, thanks for the tips. I looked at the "Retrieving Conversations from MSN Messenger" ( http://www.codeproject.com/cpp/msnchattext.asp ) to learn how to get the hwnd, like you said.
Then i used
SendMessage(hwnd, WM_SETTEXT, NULL, (LPARAM) "This is really cool lol"); .
Thanks for the help.
|
|
|
|
|
have you tried using short names for the linkage? Or, Try removing file:///? Or, hardcode the styles?
hth
|
|
|
|
|
|
Hey,
Im having allot of difficulty finding the code for converting bmp to raw,
anyone know where i can find the code for it, or find a book to read this stuff from. Both ways can help
Thanks alot
|
|
|
|
|
Hi There,
I am working on a project where I have a standalone desktop application written in VC7. This app can also be embedded into other applications through the OCX control of this app.
Now I also have a test app written in VB8 which embedds the Ocx control. I have everything in place up and running.
Now I want to add a functionality to my OCX control to enable/disable Right
Click. I am stuck in here and not able to move forward.
Plz Help Me!
Thanks in Advance ...
Aryan
|
|
|
|
|
Running the GDI+ under my development computer it works fine. I can pick a photo an view it in a preview window.
When i am making the release mode including in the same directory the gdiplus.dll when i pick a photo i get nothing (no preview).
Does the GDI+ needs a special installation under the target computer ?
Regards,
sdancer75
|
|
|
|
|
hi all
I saw this in somebodys code and I am confused
void operator() (LPCTSTR lpszFormat, ...)
{
}
what is this for ?
(LPCTSTR lpszFormat, ...)
can somebody explain. (what is here ... for)
thank you.
|
|
|
|
|
Looks like the object is being used as a functor?
"..." is for variable arguments. Since you need to know the number and types of arguments in the variable argument list, this information has to be found in the lpszFormat string for this function, like how the printf() function works.
|
|
|
|
|
... is called ellipses (msdn)[^]. It is used to pass variable number of arguments to a function..
-Saurabh
|
|
|
|
|
Hi,
Is there any way to capture the events of a dynamically created CPropertySheet ?
The code looks like the following where the m_Sheet member is the CPropertySheet.
m_Sheet.AddPage (&m_SheetBasic);
m_Sheet.AddPage (&m_SheetDetails);
m_Sheet.AddPage (&m_SheetExtras);
m_Sheet.AddPage (&m_SheetPhoto);
m_Sheet.Create (this, WS_TABSTOP | WS_CHILD | WS_VISIBLE,WS_EX_CONTROLPARENT);
m_Sheet.SetWindowPos (NULL,0,130, 0,0,SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
I would like to capture the change sheet (tab) event. Is that possible since there is no ID code ?
Regards,
sdancer75
|
|
|
|
|
I need to get the name of current module (dll). I dont have the HMODULE or the name of the module.
Thanx n Advance
AD
|
|
|
|
|
void *ptr = ...;
HMODULE hnd = NULL;
char str[MAX_PATH] = "";
if( ptr ) GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, ptr, &hnd);
if( hnd ) GetModuleFileNameA(hnd, str, __countof(str));
Where ptr is set to a pointer to a function or (dll global) variable that belongs to the dll.
By 'current module' i assume you mean you are in a function that resides in a dll and you want to find what dll.
...cmk
Save the whales - collect the whole set
|
|
|
|