Solved

Adding an object to a form at runtime

Posted on 1998-07-23
4
167 Views
Last Modified: 2010-04-04
First off I'm using C++ builder 3... similar to Delphi ... so any delphi code will help me ...I'd post my question in C++ section, but since it's a VCL thing, you guys are probably my best source.

I want to add a DriveComboBox to a form at run time.

After declaring a pointer variable to the object, and creating the object... I can access it's properties, but I can't see it on my form.... Is there a way to do this??

my code in C++ is

TDriveComboBox *Dr1;

Dr1 = new TDriveComboBox(Form1);

....
now properties can be accessed...
but DriveComboBox is NOT visible on the form
0
Comment
Question by:rafy
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
arh earned 50 total points
ID: 1358576
You should do this just after creating your control:
Dr1.parent:=Form1;
0
 
LVL 1

Expert Comment

by:arh
ID: 1358577
sorry, it was Delphi syntax..
Dr1.Parent=Form1; // right?
0
 

Author Comment

by:rafy
ID: 1358578
Dr1->Parent = Form1;
to be exact...

Perfect, thanks.

By the way, do I have to free the memory that I allocated for this object, or will the form automatically do the clean up for me when I close it.
0
 
LVL 1

Expert Comment

by:arh
ID: 1358579
Owner (which you give as an argument to constructor call) will always destroy
component object.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 302
Magic Software info 18 130
RESTRequest Parameter 4 30
scroll down TListBox component in Delphi 1 7
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question