Is money supply affected by the stock market? Do stock prices have any effect on the money supply of an economy? Please provide a simple example if possible.

Intuition suggests there is more money around when prices are high (consider for instance the dotcom boom). I guess the answer may be dependent on what definition of money supply one uses (M0-M4).
They may, but probably not much. Because stocks cannot be used as a substitute for money in most transactions there is no direct channel. However, because stocks can act as collateral for loans, and loans have the capacity to create money through the money multiplier mechanism they can have some effect, just as anything that relaxes borrowing constraints could increase the money supply. 

Collateralized loans make up the vast majority of bank debt. Suppose, for example, that banks only made collateralized loans. Then when stock prices go up, some borrowers formerly at the limits of borrowing constraints due to limited collateral, would be able to take out additional loans. These loan proceeds could then be deposited in banks or spent, either way likely ending up in banks eventually where, through the mechanism of fractional reserve banking, they could be used to create additional money. However, as you can see in the figures below, margin debt is a very low fraction of GDP in contrast to say household overall debt. So in general this is not going to be a big channel. 


Source: Ominous Sign as Margin Debt Continues to Rise 


Source: Wikipedia Subprime mortgage crisis page