菜鸟!!winform程序中如何在头文件中定义函数
我在窗体上有一个按钮,一个edit,要求按一下按钮,edit上显示出"AAA",用一个函数实现,请问在头文件中和cpp文件中应该怎么做??函数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