Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Controls In Doc/View App

Status
Not open for further replies.

Sridharan

Technical User
Dec 3, 2001
523
IN
Hello All,

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??????

Thanks
Sridharan
 
I did but wondering how to add the controls during runtime. Any ideas?????

Sri
 
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.

hope that helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top