The whole idea is wrong. You got some misconception and trying to ask an implementation question based on it. The advice is only one: learn programming fundamentals and OOP. See also my comments to this answer:
CframeWnd to custom CFrameWnd dynamically at Runtime[
^].
And again, remember that re-posts are considered as abuse, by apparent reasons. You got inadequate answer just because my preoccupation with the idea that the question was more reasonable. Which wasn't the case. :-)
Instead of re-posting, do the dialogs in comments and try to modify the question; it will put it back to the top of question list.
—SA