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

Hi everybody!! I'm using Borla

Status
Not open for further replies.

MrProgrammer

Programmer
Feb 1, 2002
41
0
0
TR
Hi everybody!!

I'm using Borland C++ Builder 5.0 and I have a problem!

In my project, there is a form named Form1. Its source file is Unit1.CPP and the header file is Unit1.H . In Unit1.CPP, I declared a control array like "TImage *Squares[8][8];".
Then in Form1's show event, I wrote some code like below:

void __fastcall TForm1::FormShow(TObject *Sender)
{ int i,j;
for (j=0;j<8;j++)
for (j=0;j<8;j++)
{ Squares[j] = new TImage(this);
Squares[j]->Parent = Form1;
Squares[j]->Width = 40;
Squares[j]->Height = 40;
Squares[j]->OnClick = Square_Click;
}

Square_Click is a function that I declared in Unit1.CPP. I put its prototype into Form1's class definition in the Unit1.H as below.

class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormShow(TObject *Sender);
void __fastcall Square_Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};

But when I compile, I'm having an error like &quot;[Linker Error] Unresolved external '__fastcall TForm1::Square_Click(System::TObject *)' referenced from Unit1.OBJ&quot;

Can you help me please???

 
first, when u call square_click you need to use

square_click(Sender);

also put your declarations in the public part, where it says &quot;User declarations&quot;

:)
 
I tried that option but this time, another error is displayed : &quot;Can not convert 'void (__fastcall *)(TObject *)' to 'void (__fastcall *(__closure)(TObject *))(TObject *)' &quot;.

What does __closure means and why two statemes of &quot;(TObject *)&quot; are used??
 
When you put square click into the header file did you include the TForm1:: part? If so, then remove it. (Just a guess, BTW.) James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
No, I didn't include that. But there is another point that is interesting : I have set all the Parent properties of the TImage objects that I created at runtime to Form1 and I put the prototype of the function &quot;SquareClick&quot; into the Form1's header file. But in spite of this, I'm getting the error message &quot;Call to undefined function 'SquareClick'&quot; when I didn't include the prototype also into the Unit1.CPP. Shouldn't it be seen from Unit1.CPP??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top