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

No data is displayed during the first call.

Status
Not open for further replies.

Bachatero

Programmer
Aug 30, 2006
36
NL
Hi all,

If I call the fastcall below for the first time, nothing is displayed in the listbox(remains empty). If I call the fastcall for a second time the values (Index, EnergyX, and EnergyY) are displayed in the listbox.

Any idea why ?

Thanks in advance

Johan

//--------------------------------------------------------

void __fastcall TMainForm::bDebugPageClick(TObject *Sender)
{
int i;
AnsiString MsgStr;

DebugPage->ShowModal();

DebugPage->Label1->Caption = "Index:";
DebugPage->Label2->Caption = "EnergyX:";
DebugPage->Label3->Caption = "EnergyY:";

for (i = 600; i <= 1000; i++) {
MsgStr = AnsiString(i) + "" + AnsiString(EnergyX) + "" + AnsiString(EnergyY);
DebugPage->ListBox1->Items->Add(MsgStr);
}
}

//--------------------------------------------------------
 
I'm guessing here, but is it possible that the form needs to be created once before any components are active?


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
ShowModal() transfers control to DebugPage so that the ModalResult can be returned and evaluated. The subsequent code isn't executed until DebugPage is closed. If you really need to show the form Modally, then you need to populate the form with any values you want to see before the ShowModal call. If you don't need it Modal, then don't make it modal and just use DebugPage->Show().
 
Thanks James and itsgsd for your valueable input

I found what went wrong. I changed the code as follows:

void __fastcall TMainForm::bDebugPageClick(TObject *Sender)
{
int i;
AnsiString MsgStr;

DebugPage->Label1->Caption = "Index:";
DebugPage->Label2->Caption = "EnergyX:";
DebugPage->Label3->Caption = "EnergyY:";


for (i = 600; i <= 1000; i++) {
MsgStr = AnsiString(i) + "" + AnsiString(EnergyX) + "" + AnsiString(EnergyY);
DebugPage->ListBox1->Items->Add(MsgStr);
}

DebugPage->ShowModal();

}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top