regarding the list constructhook
The hook function itself has the following form:function ConstructHook(hook: pHook; pool: APTR; Element: Pointer): ULONG;
- hook is a pointer to struct hook
- pool is a pointer to a memorypool, you can use it to 'add' memory to the pool that needs to be allocated (if any)
- Element being the current element in the list (f.e. data inserted with MUIM_List_Insert)
It's a little out of scope to get into the inner workings of pools, but you could perhaps compare it a little as a closet with different compartments.
The closet being the complete pool and the individual compartments being 'puddles' of small allocated memory regions that belong to the 'pool'/closet.
More information about memory pools can be read here
Now, in the List's constructhook you _can_ (not must) use the memory pool for whatever you see fit. If you need to allocate a dynamic structure that needs to be displayed in the list for example.
In my CheckListView example i didn't use the construct hook at all, because i used static data which memory allocation is handled by the compiler -> that was a design decision on my part.
No matter what, in case you used the pool variable to add your dynamically allocated memory using AllocPooled() (f.e. to be able to hold an single element of your structured data), then you are obligated to use the destructor hook to free up that allocated memory again (using FreePooled() for each item being 'handled' by the destructor ).
The element variable, is the current listitem being 'handled' by the constructor. Usually this is a pointer to char(array), but it can be a pointer to a structure or even a simple number. In theory it can be anything you want it to be, in practice it's often (and by default) just a simple string.
Important in the constructhook is the fact that the returnvalue of the construct hook that you have returned (usually the pointer to the AllocPooled memory after you filled it with your structured data) is being used by the list to be passed along to the displayhook.
As can been seen in my previous post (about displayhook), that returned pointer corresponds to the element variable in the displayhook.
Because you were responsible for allocating the memory and fill it with some sensible data, you actually know what the structure of that data is and you can use it in the display hook to do with that data whatever you want to do with it.
For example, lets say you have the following structure (just 4 simple strings, occupying 4*4 bytes = 16 bytes of memory on a 32 bit machine):
PMyData = ^TMyData;
TMydata = Record
You could use the constructhook, using AllocPooled() to allocate the 16 bytes, fill the pointers to the the strings with some valid data and return the pointer you got from AllocPooled().
Once you have the displayhook in place it will pass along that pointer as element variable and you can 'extract' the data from those 4 pointers to actually retrieve the strings. Those strings could then be used to be returned in the displayhook so that the list actually display those strings.
How the list displays those strings is also up to you. You could concatenate these 4 strings and display them as a single string in the list, but you could also 'divide' them using separate columns (using columns is another topic on it's own).
The Destructhook would also pass along that same pointer (for each dynamic allocated structure) so that you can use it to neatly free the memory again using the FreePooled() function.
The examples for parts 8 and 9 of Krashan's MUI tutorial are now in place, so feel free to browse around and see if those examples make any sense to you. In case you have questions then please feel free to ask.
Also for those that know, in case i have explained something not quite correctly, please feel free to correct -> i'm still learning