Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding an object to a form at runtime

Posted on 1998-07-23
4
Medium Priority
?
176 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

926 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