Someone already wrote one (of course)

http://codeproject.com/cs/menu/rebarcontrol.asp