Hello everyone. I am new (very very new) in programming and have knowledge of the very basic stuff in programming. I am currently working on a project in c++ builder and i have encountered a problem.
I've defined a function which activates at the press of a button. The function creates various objects in TForm1, and 2 of these objects are ListBoxes. Since i wanted the options in the ListBox2 to depend on the options in ListBox1, i tried to create a __fastcall function which activates whenever ListBox1 is clicked. The only problem is that i don't know the syntax for to use in an internal __fastcall function. I will paste here a part of the code:
The actual values in quotes " " don't matter, the idea matters - it doesn't work.Code:void asezare() { TEdit *Edit3,*Edit4; TLabel *Label3,*Label4,*Label5; TListBox *ListBox1,*ListBox2; Edit3=new TEdit(Form1); Form1->InsertControl(Edit3); Edit3->Left=Form1->Edit1->Left-245; Edit3->Top=Form1->Edit1->Top; Edit3->Width=20; Edit4=new TEdit(Form1); Form1->InsertControl(Edit4); Edit4->Left=Form1->Edit2->Left-245; Edit4->Top=Form1->Edit2->Top; Edit4->Width=20; Label3=new TLabel(Form1); Form1->InsertControl(Label3); Label3->Left=Form1->Label1->Left-315; Label3->Top=Form1->Label1->Top; Label3->Caption="Coordonata numerica"; Label3->AutoSize=true; Label4=new TLabel(Form1); Form1->InsertControl(Label4); Label4->Left=Form1->Label2->Left-315; Label4->Top=Form1->Label2->Top; Label4->Caption="Coordonata alfabetica"; Label4->AutoSize=true; ListBox1=new TListBox(Form1); Form1->InsertControl(ListBox1); ListBox1->Left=Edit3->Left+30; ListBox1->Items->Add("Orizontal"); ListBox1->Items->Add("Vertical"); ListBox1->Top=Edit3->Top; ListBox1->Height=30; ListBox1->Width=65; Label5=new TLabel(Form1); Form1->InsertControl(Label5); Label4->Left=ListBox1->Left; Label4->Top=ListBox1->Top-12; Label4->Caption="Pozitia"; Label4->AutoSize=true; ListBox2=new TListBox(Form1); ListBox2->Left=Edit3->Left+60; ListBox2->Top=Edit3->Top; ListBox2->Height=30; ListBox2->Width=65; void __fastcall TForm1::ListBox1Click(TObject *Sender) { if(ListBox1->ItemIndex==0) {ListBox2->Items->Clear(); ListBox2->Items->Add("Sus"); ListBox2->Items->Add("Jos"); } if(ListBox1->ItemIndex==1) {ListBox2->Items->Clear(); ListBox2->Items->Add("Dreapta"); ListBox2->Items->Add("Stanga"); } } }
The errors i get are:
[C++ Error] Unit1.cpp(69): E2089 Identifier 'ListBox1Click' cannot have a type qualifier
[C++ Error] Unit1.cpp(92): E2139 Declaration missing ;
[C++ Error] Unit1.cpp(92): E2190 Unexpected }
Any help is welcome.
Thank you very much.


LinkBack URL
About LinkBacks




Reply With Quote



Bookmarks