Hey all,
I have a small problem with my program. My program uses listview columns, and it works well. Well, until I get further down the list one listitem seems to be garbage. Then the list works again. Then another one is garbage.
Here is my DisplayHook function:
void FileListDisplay(struct Hook *hook, char **array, struct FileAreaEntry *e)
{
if (e)
{
*array++ = e->Filename;
*array++ = e->Deleted;
}
else
{
*array++ = GetString(MSG_FILENAME_HEADER);
*array++ = (PrefsConfig->FE_ShowKB==0 ? GetString(MSG_FILESIZE_HEADER) : GetString(MSG_FILESIZEKB_HEADER)); //newFileSize;
}
}
The FileAreaEntry struct like this:
struct FileAreaEntry
{
STRPTR Deleted;
STRPTR Filename;
};
The filelist object:
ObjectApp->filelist = ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_Format, "P=\33l BAR,P=\33r",
MUIA_List_Title,TRUE,
MUIA_List_Active, MUIV_List_Active_Top,
MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
MUIA_List_DestructHook, MUIV_List_DestructHook_String,
MUIA_List_DisplayHook, &FileListDisplayHook,
End;
Also; the filelist is an mem allocation:
#define MAXFILES 4000
struct MyFileList
{
NameT FileSize;
NameT FileName;
};
#define SIZEOFFILEINFO sizeof(struct MyFileList)
static struct FileAreaEntry fa;
struct MyFileList *myFileList;
myFileList = malloc((32*MAXFILES)+SIZEOFFILEINFO*MAXFILES);
The InsertFile function:
void InsertFile(char *fdel,char *fname)
{
fa.Filename = fname;
fa.Deleted = fdel;
DoMethod(App->filelist,
MUIM_List_InsertSingle,
&fa,
MUIV_List_Insert_Bottom);
}
Please help, I can't seem to get this fixed. The garbage is always in column 0 (Filename). Like the pointer is not working on this specific list item. Is my FileListDisplay wrong?
I have included a screenshot showing this.
Thanks in advance,
Docster