I think that the best way to do it is to derive a class from CCmdTarget. I would make this class a base class for all shapes.
You have to override the functionality of OnCmdMsg and call specific message handlers for each event you want treated.
You will find more details in the MSDN, at CCmdTarget.
I think that there is a sample in VC similar to what you want.
Anyway, the discussion above is valid only if you use Visual C++ 6.0. If you use Visual C++ .NET, things are much simpler.