Solved

Adding an object to a form at runtime

Posted on 1998-07-23
4
161 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now