 |
|
 |
can anyone suggest me about my final year project?
|
|
|
|
 |
|
 |
Plz send me this whole project to save and load data as i m in need of that .
Plz send me on my id
anuj_vohra83@yahoo.co.in
anuj vohra
|
|
|
|
 |
|
 |
This is a neat idea however it is very severly flawed with various bugs:
In the Save() routine you are allocating a whole stack of CString objects which are never being freed up which means everytime this routine is called it will leak memory (the same for loading too, but worse as more memory is leaked as you are also allocating bytes up to the 'max length' that are never freed)
In these routines you do not need to allocate any memory in this way, just get rid and use a simple CString object on the heap. In the Load() routine you may want to allocate a number of bytes but you MUST remember to do a delete[] temp; Also in this routine MaxItems is a redundant variable. It does nothing. It would be better to have the default as the number of items in the list instead of the arbitrary value of 999.
The actual file format being used is very limited and EXTREMELY inefficient. A better idea might be to encode a control character that acts as an end of line marker - normally for text files this would be a simple carriage return and there are standard runtime library methods that can do this for free!
Below is the kind of thing that I meant - just the SaveList() routine but should get you on the right lines. I have removed the MaxItems and MaxItemLen stuff as they are pretty much pointless, and this routine uses a simple CR/LF pair to determine the end of each line. Obviously the LoadList() routine would need to take account of this. There are in fact RTL methods that can read and write text files line by line (I thing these are fgets and fputs but not sure). Also, I have not tested this code in a compiler for syntax as its just to show you what I mean..
void CListBoxSafe::SaveList(CListBox &list, CString FileName)
{
int nCount = list.GetCount();
CString strData;
CFile sav;
if(sav.Open(FileName, CFile::modeCreate|CFile::modeWrite))
{
for(int i=0;i<=count-1;i++)
{
list.GetText(i,strData);
sav.Write(strData,strData.GetLength());
sav.Write("\r\n",2);
}
}
}
Keep up the good work and hope this helps!
|
|
|
|
 |
|
 |
Err yea lol, I know it's crap. I wrote this like when I was 16 or something I can't remember, I was still only getting into C++ classes and the whole deal. I haven't really updated it or anything cause I just realised how pointless the entire thing was. I would redo it and take away MFC dependencies and just use plain Win32 but like.. this class is pretty useless. I suppose better would be to write serialization functions for every standard control available, maybe that'd be worth an article. But for all I'm concerned right now they could remove this, because it was more of an experiment on writing a class
Kuniva
--------------------------------------------
|
|
|
|
 |
|
 |
Good anyway. At last, useable code.
|
|
|
|
 |
|
 |
Im really new at this, but I am putting together a nifty little program.
Here is the problem...
My list box is now displaying more than one line per line.
For example:
List.txt contains:
Item1
Item2
Item3
Item4
But the list box is displaying:
Item1[][]Item2
Item3[][]Item4
(Where the [] represents a square symbol)
What am I doing wrong?
Travis
|
|
|
|
 |
|
 |
i am a member and cant down load it .asp stuff not zip
can any one email it to me
terry@hughes5045.fsnet.co.uk
thanks
|
|
|
|
 |
 | error  |  | Anonymous | 9:52 2 Sep '02 |
|
 |
my listbox is: m_list(control)
why when i use int i = m_list.GetCount();
my program crash
help please
i use that class but is same think
|
|
|
|
 |
|
 |
How can i use this class??
Please help me.
|
|
|
|
 |
|
 |
Thank you so much, I spent hours and hours trying to do just that, save and load listboxes. I asked numerous people, who seemed not to know a thing about it so finally I had to do this. I had to make a max number of items (a low 30) and then save every one of those to an indivisual string. I have not tried this out yet, but I'm very excited.
|
|
|
|
 |
|
 |
I too am a 16 year old programmer (...well sort off) that started at 14. If i Was you I would put a little error checking in there...as it is going to be run on Windows....god's knows what could go wrong.
==================================================
When Your Mind Wonders....Where Does It Go???
|
|
|
|
 |
|
 |
wow cool, thanks for giving it a 4!!!
Never thought i'd get that lol.
So your 16 huh? cool. I became 17 recently. Like, where do you live n stuff? Do you got MSN? We could like exchange things and knowledge ... if you want..? Got MSN?
Kuniva
P.S.: i'm working on the error handlers
|
|
|
|
 |
|
 |
It's cool to see some programmers around my age =) hehe
Well, I'm 17 now, and I started learning C++ like 3 years ago, nice class btw, i like it
i was making a program and i was looking for some class or function to save/load data from a file, and here it is, thanks to YOU! =)
-MNS
-E-Mail Address/MSN: q8mns@hotmail.com
-ICQ: 71708599
|
|
|
|
 |
|
 |
While I'm at it, I might add that I'm also 16. I had no idea there were that many of us out there. My MSN name is Selevercin@hotmail.com if you want to exchange knowledge!
|
|
|
|
 |
|
 |
Its good to see there are so many young programmers. I too started when I was 14 and am now 21 working as a Software Engineer getting phat paid! All I gotta say is keep up the work, go to college and make lots of money. BTW, I looked at your code and I noticed that you never delete your CString pointers that you allocate which will cause memory leaks. An easier way to do this would be to only use one CString object and not a pointer like so:
CString strItem;
for (int i = 0; i < nCount; i++) {
listBox.GetText(i, strItem);
strItem += _T("\n");
sav.Write(strItem.GetBuffer(0), strItem.GetLength());
}
There should be no need to seek as the file pointer is continuous and since we append the newline char to the end of each string, each item will be on its own line and you don't need to worry about pointer cleanup as the CString class handles that. Also, you don't need to ask how many items or set a max length for each item.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
 |
|
|
 |
|
 |
Hi,
The code really works simple and fine, but the "style" of the contents in
the listbox has been changed when save it to a text file.
How to keep same style in order to make the thing looks completely same?
chen
|
|
|
|
 |
|
 |
Hi, I am also 16 and just started learning wpf 6 months ago and it is soo hard, I have asked this question on MSDN and everywhere but no one seems to know how to save and load data from a file to listbox and listbox to file. I have found this class but I do not know how to use it please if someone can help me out a bit here
|
|
|
|
 |
|
 |
Well unfortunately in order to use this class you'd have to port it to C# which isn't difficult unless you're not familiar with both C++ and C#. More importantly is this class will only work for simple string data so if you plan on displaying complex items in your WPF ListBox you'll need to write serializers for those items which also is not too difficult but its not the easiest for a beginner. If you just want to load and save strings let me know and I can port this class for you and create an example so you can see how to use it in WPF.
|
|
|
|
 |