+ -
当前位置:首页 → 问答吧 → 我自定义了一个护展中Timer控件的类,Delphi中已实现,在CB中搞不定,谢谢大家

我自定义了一个护展中Timer控件的类,Delphi中已实现,在CB中搞不定,谢谢大家

时间:2011-12-27

来源:互联网

//---------------------------------------------------------------------------
#ifndef Unit11H
#define Unit11H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
//

class TRestTimmer: public TTimer
{
private:
AnsiString FRestTypeCode;
int FRestTimeLength;
TDateTime FBeginRestTime;
bool FIsRunning;
public:
__fastcall TRestTimmer(TComponent* Owner);
__property AnsiString RestTypeCode = {read=FRestTypeCode,write=FRestTypeCode};
__property int RestTimeLength = {read=FRestTimeLength,write=FRestTimeLength};
__property TDateTime BeginRestTime ={read=FBeginRestTime,write=FBeginRestTime};
__property bool IsRunning ={read=FIsRunning,write=FIsRunning};
};



class TForm11 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TEdit *Edit1;
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TRestTimer *RestTimer;
public: // User declarations
__fastcall TForm11(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm11 *Form11;
//---------------------------------------------------------------------------
#endif

//---------------------------------------------------------------------------
#include <vcl.h>
#include <RestTimer.hpp>
#pragma hdrstop

#include "Unit11.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm11 *Form11;
//---------------------------------------------------------------------------
__fastcall TForm11::TForm11(TComponent* Owner)
: TForm(Owner)
{




}
//---------------------------------------------------------------------------


void __fastcall TForm11::FormCreate(TObject *Sender)
{
RestTimer = new TRestTimer(NULL);
}
//---------------------------------------------------------------------------

__fastcall TRestTimmer::TRestTimmer(TComponent* Owner)
: TTimer(Owner)
{


}

作者: liuhengwinner   发布时间: 2011-12-27

Error: Unresolved external 'Resttimer::TRestTimer""' referenced from e:\timetest\debug\unit1.obj

作者: liuhengwinner   发布时间: 2011-12-27

我这个cpp可以编译,你那个错误是少了构造函数的原因。
void __fastcall TForm1::FormCreate(TObject *Sender)
{
RestTimer = new TRestTimmer(NULL);
}
//---------------------------------------------------------------------------
 __fastcall TRestTimmer::TRestTimmer(TComponent* Owner)
: TTimer(Owner)
{


}

作者: ksrsoft   发布时间: 2011-12-27

TRestTimmer *RestTimer ;

作者: huakeidelukou   发布时间: 2011-12-27

自己顶一下,哎!

作者: liuhengwinner   发布时间: 2011-12-27

你的到底是啥情况,我这个可以完全编译成功
C/C++ code

------------头文件-------------------------------
#ifndef Unit1H
#define Unit1H
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
class TRestTimmer: public TTimer
{
private:
AnsiString FRestTypeCode;
int FRestTimeLength;
TDateTime FBeginRestTime;
bool FIsRunning;
public:
__fastcall TRestTimmer(TComponent* Owner);
__property AnsiString RestTypeCode = {read=FRestTypeCode,write=FRestTypeCode};
__property int RestTimeLength = {read=FRestTimeLength,write=FRestTimeLength};
__property TDateTime BeginRestTime ={read=FBeginRestTime,write=FBeginRestTime};
__property bool IsRunning ={read=FIsRunning,write=FIsRunning};
};

class TForm1 : public TForm
{
__published:    // IDE-managed Components
    void __fastcall FormCreate(TObject *Sender);
private:    // User declarations
TRestTimmer *RestTimer;

public:        // User declarations
    __fastcall TForm1(TComponent* Owner);
};
extern PACKAGE TForm1 *Form1;
#endif

-------------cpp文件-----------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
RestTimer = new TRestTimmer(NULL);

}
__fastcall TRestTimmer::TRestTimmer(TComponent* Owner)
: TTimer(Owner)
{
}



作者: ksrsoft   发布时间: 2011-12-27

呵呵,直接用定时器不就可以了吗

作者: loveheronly   发布时间: 2011-12-27