|
CTreeCtrl is different from those listboxes or list controls. It doesn't have an index. Instead you get handle to a particular item and using that, you can get its child item and so on.
|
|
|
|
|
To complete Mr Chen's post, you can emulate an indexing of items using the Data member of the items in the TreeCtrl. It is accessible using SetItemData and GetItemData
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
|
hi all,
i am using a char *did = "141335678567" in my application and when i am exiting my application will it leads to memory leak ?
Thank you all
venu
|
|
|
|
|
can you show code, how you are using it?
|
|
|
|
|
// m_strUserID is a global variable where i get some value// some userid values
char *charUsrId = m_strUserID.GetBuffer(m_strUserID.GetLength());
char *chDefaultIP = m_strDefaultDomain.GetBuffer(m_strDefaultDomain.GetLength());
i am using like this is it correct ?
venu
|
|
|
|
|
g venu wrote: char *charUsrId = m_strUserID.GetBuffer(m_strUserID.GetLength());
char *chDefaultIP = m_strDefaultDomain.GetBuffer(m_strDefaultDomain.GetLength());
there is no problem using this way,
but make sure you call ReleaseBuffer on CString object, before using it for any other operation.
And ofcourse there is no memory leak.
|
|
|
|
|
|
prasad_som wrote: but make sure you call ReleaseBuffer on CString object, before using it for any other operation.
And ofcourse there is no memory leak.
If you don't call ReleaseBuffer, you will get a memory leak.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: If you don't call ReleaseBuffer, you will get a memory leak.
I agree, I was in assumption ReleaseBuffer is been used after call to GetBuffer. My statement was assumming that
|
|
|
|
|
g venu wrote: char *charUsrId = m_strUserID.GetBuffer(m_strUserID.GetLength());
char *chDefaultIP = m_strDefaultDomain.GetBuffer(m_strDefaultDomain.GetLength());
you have to call associated ReleaseBuffer() api of CString Class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
AFAIK A memory leak occurs when we don't free a block of memory allocated with the new operator.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
No, not al all if you are actually exiting.
It'll be freed automatically when the program is terminated.
|
|
|
|
|
I want to store current time to a text file. And i want to retrieve that value afterwards and want to compare with the some CTime object. So used CArchieve and failed. Here is my code
<br />
CFile TimeFile;<br />
CTime curTime = CTime::GetCurrentTime();<br />
if(!TimeFile.Open<br />
("TimeFile.txt"<br />
,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite))<br />
{<br />
return;<br />
}<br />
CArchive arTimeFile(&TimeFile, CArchive::store,512);<br />
arTimeFile << curTime;<br />
TimeFile.Close();<br />
I am getting debug error and it shows
void CFile::Write(const void* lpBuf, UINT nCount)<br />
{<br />
ASSERT_VALID(this);<br />
ASSERT(m_hFile != (UINT)hFileNull);<br />
--------<br />
please help me.
KIRAN PINJARLA
|
|
|
|
|
insert line arTimeFile.Flush()after writing data to archive.
your code will be like this,
CFile TimeFile;
CTime curTime = CTime::GetCurrentTime();
if(!TimeFile.Open
("TimeFile.txt"
,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite))
{
return;
}
CArchive arTimeFile(&TimeFile, CArchive::store,512);
arTimeFile << curTime;
arTimeFile.Flush();
TimeFile.Close();
|
|
|
|
|
Thank you prasad. It did work.
Now I need a little more help. I want to read that CTime object from that file and want to compare with another CTime object. I wrote like this
CArchive arTempFile(&TimeFile, CArchive::load);<br />
CTime tempTime;<br />
arTempFile >> tempTime;
</big>
How to do this.
Thank you
KIRAN PINJARLA
|
|
|
|
|
what error its showing ? you need to use flush() this time,too.
I've tested same code here, its not giving any error.
|
|
|
|
|
Prasad. I got it. It is working. It was my fault.I have given a wrong object name.
Thank you somuch for ur help.
GOOD LUCK.
KIRAN PINJARLA
|
|
|
|
|
hi all,
its very basic question but i don't know how to do this in win32,
how to create a binry file .
can i create it with CreateFile.
please let me know.
Thanks and regards
Harshal
|
|
|
|
|
If you are using only win32 (an no MFC), I would suggest that you use FILE (with fopen, fclose, fread, fwrite, ...). To start with it, you can have a look here[^]
If you are using the MFC, then I would suggest that you use the CFile class.
|
|
|
|
|
i am using MFC i tried with CFile::Open
with binary flag but it is not working
so now i will try fopen only because i am not going to
read the data from the file.
i will write and append to it.
|
|
|
|
|
harsha_1234 wrote: with binary flag but it is not working
It should work. If you coul provide more information, maybe we can help. What do you mean by 'it is not working' ? Crash, no file created, compile error, ... Give as much detail as possible.
|
|
|
|
|
|
what do you want to store in it ?
BTW, in C++, prefer STL to C file handling functions (std::fstream )
|
|
|
|
|
CreateFile() do create a binary file.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|