Unfortunalty locking Messenger when you minimize the contactlist can't be done with only pure scripting because that requires subclassing (If you can create an external DLL which subclasses the main Messenger window then it is possible).
However, locking Messenger when you close the contactlist window is possible.
But, is there a specific reason why you don't you use the Messenger Lock shortcut or menu item for this? It has the same effect though...
As for the code to lock Messenger when you close the contactlist, all you need is:
js code:
function OnEvent_ContactListWndDestroyed() {
if (!MsgPlus.MessengerIsLocked) MsgPlus.LockMessenger(true);
}