escheider
asked on
Creating controls at runtime
Good afternoon experts:
I'm trying to locate some documentation on creating controls at runtime without much sucess. I have a combobox that lists the different types of controls, and when the user selects a control in the combo box, I'd like to create it.
Could you provide an example of how to create a control, like a radio button or textbox, during runtime?
I'm using C++.NET 2005
Any help is appreciated.
I'm trying to locate some documentation on creating controls at runtime without much sucess. I have a combobox that lists the different types of controls, and when the user selects a control in the combo box, I'd like to create it.
Could you provide an example of how to create a control, like a radio button or textbox, during runtime?
I'm using C++.NET 2005
Any help is appreciated.
ASKER
I'm fairly new to VC++.NET, so I'm using Windows Forms, not MFC, and I'm finding a lack of information on the subject.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Dan, this got me on the right path. I appreciate it.
CComboBoc
CEditCtrl
CButton
... etc...
See http://msdn.microsoft.com/library/en-us/vclib/html/vclrfMFCClassListing.asp
Each of these object has a "Create" memeber function. You can specify various "style" options in that call as well as the on-screen location to display the control. For instance, in a dialog box, you could use code like:
static CButton myBtn;
myBtn.Create( "My button", WS_CHILD|WS_VISIBLE|BS_PUS
and a button would appear in the dialog. There would be additional steps to take if you need to be able to take action when the button gets clicked (etc.) but the Create function is what you need to use to create it in the first place.
-- Dan