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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I define and insert a control at runtime?

Status
Not open for further replies.

barbacot

Programmer
Feb 5, 2002
4
FR
I wrote the following code, but the ComboBox doesn't display. Is the same thing for any other control.

CComboBox c;
c.Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 50, 50), this, 1047);
c.ShowWindow(SW_SHOW); // this should be the default, anyway

The Create() function returns TRUE, I checked. So what is missing / wrong?
 
You should create CCombox instance in the heap instead of the stack, because memory is released after your CComboBox instance goes out of the function scope.
use:

CComboBox *c = new CComboBox;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top