 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
James Peterson Guest
|
Posted: Mon Nov 10, 2003 6:29 pm Post subject: help with dynamic buttons |
|
|
ok I have this.
but it tells me I Spec_Sheet is an undifened symble. If I put it all into
one function it works great. just doesn't work in sparate function. How can
I fix this so i can have separete funtions to do this.
void __fastcall TForm1::Label1Click(TObject *Sender)
{
StaticText1->Caption = "Creating Form";
TForm *Spec_Sheet = new TForm(this);
Spec_Sheet->Left = 100;
Spec_Sheet->Width = 600;
Spec_Sheet->Top = 100;
Spec_Sheet->Height = 500;
Spec_Sheet->Caption = "Specification Sheets";
ProgressBar1->StepBy(50);
//new
TForm1::Spec_New_Button(this);
Spec_Sheet->ShowModal();
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Spec_New_Button(TObject *Sender)
{
TBitBtn* Spec_New = new TBitBtn(this);
Spec_New->Enabled = true;
Spec_New->Left = 110;
Spec_New->Width = 50;
Spec_New->Top = 110;
Spec_New->Height = 50;
Spec_New->Visible=true;
Spec_New->Parent=Spec_Sheet;
ProgressBar1->StepBy(50);
}
//--------------------------------------------------------------------------
-
|
|
| Back to top |
|
 |
Timothy H. Buchman Guest
|
Posted: Mon Nov 10, 2003 9:16 pm Post subject: Re: help with dynamic buttons |
|
|
"James Peterson" <jpeterson (AT) romanmealmilling (DOT) com> wrote
| Quote: | ok I have this.
but it tells me I Spec_Sheet is an undifened symble. If I put it all
into
one function it works great. just doesn't work in sparate function.
How can
I fix this so i can have separete funtions to do this.
|
James, you don't say in which function the error occurs. But I think
it's the second:
| Quote: |
void __fastcall TForm1::Label1Click(TObject *Sender)
{
StaticText1->Caption = "Creating Form";
TForm *Spec_Sheet = new TForm(this);
snip
void __fastcall TForm1::Spec_New_Button(TObject *Sender)
{
TBitBtn* Spec_New = new TBitBtn(this);
|
Not sure, but could this better be TBitBtn(Sender) ? I forget if
Sender needs a cast to do that.
| Quote: | Spec_New->Enabled = true;
Spec_New->Left = 110;
Spec_New->Width = 50;
Spec_New->Top = 110;
Spec_New->Height = 50;
Spec_New->Visible=true;
Spec_New->Parent=Spec_Sheet;
|
Isn't your intent that the *parent* and the *owner* be the same form,
Spec_Sheet? The tidiest way would be to derive a new component
TSpecSheet from TForm, that would have SpecNewButton as a member
function. Then "this" tells you everything. Making Spec_Sheet a
global variable is the wrong solution, so I won't propose it. If
there's never more than one Spec_Sheet, you could make it a member
variable of TForm1 (in the user part of the BCB generated header), and
use its' fully qualified name here. That might (but I don't have all
your code) be Form1->Spec_Sheet, or MainForm->Spec_Sheet.
--
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenterD O Torg
Search .borland message archive on http://www.tamaracka.com/search.htm
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|