主题:求解一题,错误怎么改啊?
简单的只有两个窗体!
Unit1.cpp的代码是
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Perform(WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
SendMessage(Form2->Handle,WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
PostMessage(Form2->Handle,WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
TMessage M;
M.Msg=WM_LBUTTONDOWN;
Form2->Broadcast(&M);
}
//---------------------------------------------------------------
的代码是:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall TForm2::FormCreate(TObject*Sender)
{
Form2->Show();
}
//-----------------------------------------------------------------------------
void __fastcall TForm2::Panel1Click(TObject *Sender,
TMouseButton Button,TShiftState Shift,int x,int y)
{
Panel1->Caption="Down";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Panel2Click(TObject *Sender,
TMouseButton Button,TShiftState Shift,int x,int y)
{
Panel2->Caption="Down";
}
//---------------------------------------------------------------------------
Unit2.cpp错误提示:
[C++ Error] Unit1.cpp(17): E2316 '_fastcall TForm1::Button1Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(22): E2316 '_fastcall TForm1::Button2Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(27): E2316 '_fastcall TForm1::Button3Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(32): E2316 '_fastcall TForm1::Button4Click(TObject *)' is not a member of 'TForm1'
请问怎么改啊?我照书上写的!
Unit1.cpp的代码是
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Perform(WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
SendMessage(Form2->Handle,WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
PostMessage(Form2->Handle,WM_CLOSE,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
TMessage M;
M.Msg=WM_LBUTTONDOWN;
Form2->Broadcast(&M);
}
//---------------------------------------------------------------
的代码是:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall TForm2::FormCreate(TObject*Sender)
{
Form2->Show();
}
//-----------------------------------------------------------------------------
void __fastcall TForm2::Panel1Click(TObject *Sender,
TMouseButton Button,TShiftState Shift,int x,int y)
{
Panel1->Caption="Down";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Panel2Click(TObject *Sender,
TMouseButton Button,TShiftState Shift,int x,int y)
{
Panel2->Caption="Down";
}
//---------------------------------------------------------------------------
Unit2.cpp错误提示:
[C++ Error] Unit1.cpp(17): E2316 '_fastcall TForm1::Button1Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(22): E2316 '_fastcall TForm1::Button2Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(27): E2316 '_fastcall TForm1::Button3Click(TObject *)' is not a member of 'TForm1'
[C++ Error] Unit1.cpp(32): E2316 '_fastcall TForm1::Button4Click(TObject *)' is not a member of 'TForm1'
请问怎么改啊?我照书上写的!