Is it possible to add controls(ListBox, ComboBox etc) to a Doc/View App at Runtime based on some condition??? If so, can anyone tell me how to do that??????
Yes, you have to create them on the fly (a new CButton, for instance) having as parent the dialog you want to put them in.
Then be sure to assign a new ID to your control, an ID that your parent dialog is aware of, for example:IDC_NEW_BUTTON.
In the dialog's wnd proc watch then for messages that have as destination the new control and act correspondingly to it.
I never done it so far, but this is the way I'd do it.
Hopefully it works... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal... once stated: methane@personal.ro
A common approach to doing that is to put CWnd derived classes in your application then use CWnd::Create() or even an override of it in the derived class.
Here is where I have a class derived from CTreeCtrl and I create it dynamically in my applicaiton.
Code:
VERIFY(_tree.Create( this, ID_DOCTREE));
as Nosferatu stated, you can see i created a resource/symbol ID for the control. My CView derived class has the "_tree" member variable.
Now it's that simple to "create" the window. Managing it's position and size and getting data in and out of it and responding to user events must be handled and of course you will not be able to use "Class Wizard" in the normal fashion to accomplish that.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.