How do I assign a "minimizing to tray" function to the originally "minimize" button. And how do I actually write the minimizing to tray function?

Hope one of you can help