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

Can't display an edit control on a form 1

Status
Not open for further replies.

thompsm

Programmer
Dec 23, 2002
6
0
0
US
I want to write a program that will create a GUI on the fly based on commands it receives from another program. I created a new application in Borland C++Builder 6. It creates the standard form. I tried to add an edit control to the form without using the designer. I tried the following:

#include <vcl.h>
#pragma hdrstop
TEdit *Edit2;
TComponent *AOwner;
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Edit2 = new TEdit(AOwner);
Edit2->Enabled = true;
Edit2->Name = "Edit2";
Edit2->Height = 21;
Edit2->Left = 360;
Edit2->Text = "Edit2";
Edit2->Top = 152;
Edit2->Visible = true;
Edit2->Width = 177;
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}


The program runs but no edit control appears on the screen. Can anyone help me with this?

Thank you very much.
 
Hey,

I did not know that one could do this to workaround the "Formcreate" and workaround a main.cpp.

but, in order to have it shown, it maybe lacks a "Parent":

Try to insert the following line:

Edit2->Parent = Form1;
after the "new TEdit" line.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top