#2
修雅2012-08-07 15:45
//unit1.cpp-------------------------------------------------
#include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TMainForm::btnSunClick(TObject *Sender) { ShowAAA(); } void TForm1::ShowAAA() { Edit->Text="AAA"; } //--------------------------------------------------------------------------- //-------------------------------------------------------------------- unit1.h class TMainForm : public TForm { __published: // IDE-managed Components TButton *btnSun; TEdit *txt1; void __fastcall btnSunClick(TObject *Sender); private: // User declarations public: // User declarations __fastcall TMainForm(TComponent* Owner); void ShowAAA(); }; //--------------------------------------------------------------------------- extern PACKAGE TMainForm *MainForm; //--------------------------------------------------------------------------- #endif // 希望对你有帮助 |
函数void ShowAAA()
{
edit->text="AAA";
}
上面这段代码声明应该放在哪里,实现放在哪里??
//unit1.cpp-------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnSunClick(TObject *Sender)
{
}
//---------------------------------------------------------------------------
//--------------------------------------------------------------------
unit1.h
class TMainForm : public TForm
{
__published: // IDE-managed Components
TButton *btnSun;
TEdit *txt1;
void __fastcall btnSunClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
{
edit->text="AAA";
}
上面这段代码声明应该放在哪里,实现放在哪里??
//unit1.cpp-------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnSunClick(TObject *Sender)
{
}
//---------------------------------------------------------------------------
//--------------------------------------------------------------------
unit1.h
class TMainForm : public TForm
{
__published: // IDE-managed Components
TButton *btnSun;
TEdit *txt1;
void __fastcall btnSunClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif