Thread: Looking for a way to store listbox data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100

    Looking for a way to store listbox data

    This question is referring to a program I am writing for Windows, but the code I am asking for can be ANSI C.

    I have a listbox containing a list of frames in an animation. I want to store some data associating with each frame. The data I want to store is: Frame Number, Frame Delay, X Offset, Y Offset, Loop Count, File Path, File Name

    Now I wrote some code that uses a typedef struct to store the data, then I created a new array of them like this:
    Code:
    typedef struct animationstructure
    {
    	char filename[MAX_PATH];
    	char filepath[MAX_PATH];
    	int delay;
    	int xpos;
    	int ypos;
    	int framenum;
        	int loop;
    } imagestruct;
    
    imagestruct imagedata[500];
    I then proceeded to read/write from these and using the List Item Number as the index for the imagestruct.

    The problem I had with this method is that when I delete an item from my ListBox, I now have a gap in my data structure which gives me issues later on down the line in my program. This is not too much of a problem unless enough frames get deleted/added enough and it will eventually cause issues with the program. Now I tried to write code to make this work by using a 2nd struct, and running through a loop and copying data from one to the other then back again without the deleted item in the struct array. The code didn't really work well at all.

    So I was hoping somebody could help me out with a method of doing this. I have tried making hidden listboxes, but now I am having the program crashing and for some reason it isn't working properly. On top of that I feel it is an easy way out and I don't feel comfortable storing data in hidden controls. I would rather do it the right way. On top of that it can be optimized if I write the code myself, but not if I use Win32 API calls that do a bunch of drawing and other stuff like that.



    Pardon my programming lingo. I was a software engineer for Mac OS and embedded systems up until 2002 and I have taken a career change as a Shipyard Welder. But I am now digging back into the realm of computer programming on Windows and I am hooked all over again.

    So anyways, I appreciate any help you guys can give. And understand that my memory is very foggy on programming, so too much technical talk may lose me so try to dumb it down if you don't mind. Examples or actual code will really help.

    Thanks.
    -Nick
    Last edited by Welder; 10-29-2007 at 08:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  2. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  3. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM
  4. Do you store store one off data arrays in a class?
    By blood.angel in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2002, 12:05 PM
  5. Can applications store data in DLL's ?
    By kes103 in forum C Programming
    Replies: 6
    Last Post: 06-02-2002, 06:55 PM