我用NEW 新建一个自己的控件, 为何出错?

sdjifeng sdjifeng 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#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)
{
int f;
String fn;
if(OpenDialog1->Execute())
{
fn=OpenDialog1->FileName;

f=FileOpen(fn,fmOpenRead);
FileClose(f);
Memo1->Lines->LoadFromFile(fn); }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Memo2 = new TMemo2 ((TForm *) Sender) ;
}
//---------------------------------------------------------------------------




//---------------------------------------------------------------------------

#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TOpenDialog *OpenDialog1;
TMemo *Memo1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TMemo * TMemo2;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
class TMemo2 : public TMemo
{ private:
unsigned int size ;
};






[C++ Error] Unit2.cpp(34): E2451 Undefined symbol 'Memo2'
[C++ Error] Unit2.cpp(34): E2303 Type name expected
[C++ Error] Unit2.cpp(34): E2379 Statement missing ;







...全文
评论 15
收藏 已收藏
分享
返回顶部
sdjifeng
C++ Builder 13,871 成员 102,696 内容