# Visual C++ & C++ Programming > Visual C++ Programming >  Dynamic allocation in MFC

## Odiee

Why doesn't MFC supports dynamic creation of controls? I have found my self in many situations, where this feature would help a lot and simplify program design. (perticular in simple dialogs, where user is asked to input some data).
In that way it would be possible to create truely dynamic programs. 
By this question I meen to avoid, common post on VC++ section of CodeGuru forums  witch is: "Just create 10-50 CEdit controls on dialog, and hide them, when you need them use ShowWindow(SW_SHOW)". I greatly dissagree with this programming practice.
And another question is easy one but I haven't found an answer yet. It is about  class view in VC++. I have a problem where I add some project files, like FastObject's hxx file or MySQL or anything, and it automatically includes all classes and function found in it, and then class view is usselles couse there's just too many functions and classess, Is there a way to avoid that?

Regards:
Dario Maljur

----------


## WizBang

[ Moved ]

----------


## JohnCz

> Why doesn't MFC supports dynamic creation of controls?


Well, it does.
I am not sure what do you mean by dynamic creation.
1. It may mean instantiation of the object at the compile time and window creation at the run time.
2. Object instantiation and window creation at the run time.

Both are supported therefore I am not sure what is your question referring to.


> By this question I meen to avoid, common post on VC++ section of CodeGuru forums  witch is: "Just create 10-50 CEdit controls on dialog, and hide them, when you need them use ShowWindow(SW_SHOW)". I greatly dissagree with this programming practice.


Why? I fail to see what is wrong with it.


> And another question is easy one but I haven't found an answer yet.


 Unfortunately that is true and there is nothing you can do about it. That is the way calss view was designed.


> Why can't CButton and CEdit be dynamically allocated. . .


 They can.


> and why did I just spent 54 minutes on implementing Popup menu?


you should be able to answer this question.
You are probably in the process of learning how to do it. It takes me about 2 minutes.  :Big Grin:

----------

