Look at the CStaticLink class in the PixieLib MFC C++ Class Library from Paul DiLascia. It is for a static control, but it probably is a sample that can be used to do what you are doing.