Bob, that code doesn't compile unfortionately. A ton of errors on Bloodshed Dev C++
For example, these are not defined..
LPNMLISTVIEW
CDDS_PREPAINT
CDRF_NOTIFYITEMDRAW
There are TONS of other things like that.
Bob, that code doesn't compile unfortionately. A ton of errors on Bloodshed Dev C++
For example, these are not defined..
LPNMLISTVIEW
CDDS_PREPAINT
CDRF_NOTIFYITEMDRAW
There are TONS of other things like that.
I ain't up to snuff on my ANSI stuff but if memory serves me correctly, there isn't any strings.h header. I believe it should be string.h. I changed strings.h to string.h and it compiles.
But anyway, I would suggest that you forget about the listview stuff for now and focus on getting your original code functioning properly, one step at a time. Once it's functioning properly, you can change it to a listview.
Problem number one is that you have a wild pointer:
Set the pointer to the next node to NULL.Code:mainframeset=(struct framelist *)malloc(sizeof(struct framelist)); mainframeset->filename = (char *)malloc(MAX_PATH); mainframeset->filepath = (char *)malloc(MAX_PATH); mainframeset->delay = 0; mainframeset->loop = 0; mainframeset->xpos = 0; mainframeset->ypos = 0; mainframeset->next = NULL; AppendNode(&mainframeset, 0, 0, 0, 0, "", "");
Also, a trivial issue, the return value of the AppendNode function is a struct of type node. It should be void since the function is not returning anything.
*EDIT* Please explain what you're attempting to do with the Add Frame, Remove Frame, Safe Gif, Clear Frames and Update Frame Settings buttons in relation to your linked list. I'm totally lost here.
Last edited by BobS0327; 10-31-2007 at 05:53 PM. Reason: Need additional info
Bob, you may be right on the include file.
I will try that suggestion as well and get back to you.
Yes, I noticed that about the AppendNode. That one was not written by me. I was going to change that but then I left it because it may come in handy later to return the newly appended item so I can assign a pointer to it in my listbox's 2nd paremeter after I add an item to the listbox/linked lists.
It doesn't crash if I remove "RetrieveList" from the main code... But I can't figure out what is wrong with it. It runs fine in my console test program, but not in this Win32 API program.
When your listbox selection is zero, you will be checking for counter to equal -1 AND the current pointer to equal NULL to break out of the while loop. Counter will never equal -1 and your RetrieveList function crashes because it's in a perpetual loop.It doesn't crash if I remove "RetrieveList" from the main code... But I can't figure out what is wrong with it.
Also, the code in red is not necessary. Check the PushLinkedList function. Memory is allocated in that function.Code:struct framelist* RetrieveList(struct framelist** head, int num) { struct framelist* current = *head; int counter=0; if(current != NULL) { while(current != NULL && counter != num-1) { current = current->next; counter++; } } return current; }
Code:int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { mainframeset=(struct framelist *)malloc(sizeof(struct framelist)); mainframeset->filename = (char *)malloc(MAX_PATH); mainframeset->filepath = (char *)malloc(MAX_PATH); mainframeset->delay = 0; mainframeset->loop = 0; mainframeset->xpos = 0; mainframeset->ypos = 0; AppendNode(&mainframeset, 0, 0, 0, 0, "", ""); DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc); free(mainframeset); return 0; }
Well thanks again for all the help you guys gave, especially Salem you were a big help to me.
I ended up getting all my linked list code working, I rewrote a bunch of code in the functions I got from the tutorial to make them work for my application and will post them here when I get time (probably tomorrow) for people to learn from.
I said "screw it" to the RetrieveList() function that I wrote and ended up using a pointer to the list and storing it in my listbox with SETITEMDATA and it works beautifully.