请教一下 VCL控件制作的问题
H头文件
//---------------------------------------------------------------------------
#ifndef MyPanelH
#define MyPanelH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include <Graphics.hpp>
//---------------------------------------------------------------------------
//typedef void __fastcall (__closure *MyWM_LBUTTONUP)(System::TObject* Sender);
class PACKAGE TMyPanel : public TPanel
{
private:
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
TImage *Image1;
TSpeedButton *SpeedButton1;
TSpeedButton *SpeedButton2;
TSpeedButton *SpeedButton3;
TNotifyEvent FSp1OnClick;
protected:
public:
__fastcall TMyPanel(TComponent* Owner);
__published:
};
//---------------------------------------------------------------------------
#endif
CPP文件
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MyPanel.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TMyPanel *)
{
new TMyPanel(NULL);
}
//---------------------------------------------------------------------------
__fastcall TMyPanel::TMyPanel(TComponent* Owner)
: TPanel(Owner)
{
TImage *Image1 = new TImage(this);
Image1->Parent = this;
Image1->Width = 25;
Image1->Height = 25;
Image1->Top = this->Top;
Image1->Left = this->Left;
Image1->Picture->LoadFromFile("C:\\Documents and Settings\\Administrator\\桌面\\bmp\\1.bmp");
// (0,18,0,fpDefault,TFontStylesBase[fsBold],GB2312_CHARSET,"宋体");
TLabel *Label1 = new TLabel(this);
Label1->Parent = this;
Label1->Top = this->Top+8;
Label1->Left = this->Left+30;
Label1->Font->Style = Label1->Font->Style<< fsBold;
Label1->Font->Size = 11;
Label1->Font->Charset = GB2312_CHARSET;
Label1->Font->Name = "宋体";
Label1->Caption = "袁肇斌";
TLabel *Label2 = new TLabel(this);
Label2->Parent = this;
Label2->Top = this->Top+30;
Label2->Left = Label1->Left;
Label2->Font->Style = Label2->Font->Style<< fsBold;
Label2->Font->Size = 10;
Label2->Font->Charset = GB2312_CHARSET;
Label2->Font->Name = "宋体";
Label2->Font->Color = clBlue;
Label2->Caption = "83380000041";
TLabel *Label3 = new TLabel(this);
Label3->Parent = this;
Label3->Top = this->Top+45;
Label3->Left = Label1->Left;
// Label3->Font->Style = Label3->Font->Style<< fsBold;
Label3->Font->Size = 10;
Label3->Font->Charset = GB2312_CHARSET;
Label3->Font->Name = "宋体";
Label3->Caption = "时间: 2009-01-18";
TLabel *Label4 = new TLabel(this);
Label4->Parent = this;
Label4->Top = this->Top+60;
Label4->Left = Label1->Left;
// Label4->Font->Style = Label4->Font->Style<< fsBold;
Label4->Font->Size = 10;
Label4->Font->Charset = GB2312_CHARSET;
Label4->Font->Name = "宋体";
Label4->Caption = "时长: 18:21";
TSpeedButton *SpeedButton1 = new TSpeedButton(this);
SpeedButton1->Parent = this;
SpeedButton1->Height= 25;
SpeedButton1->Width = 25;
SpeedButton1->Top = this->Top +20;
SpeedButton1->Left = Label2->Left +Label2->Width +10;
SpeedButton1->Flat= 1;
// SpeedButton1->OnClick =Sp1Execute;
SpeedButton1->Glyph->LoadFromFile("C:\\Documents and Settings\\Administrator\\桌面\\bmp\\+.bmp");
TSpeedButton *SpeedButton2 = new TSpeedButton(this);
SpeedButton2->Parent = this;
SpeedButton2->Height= 25;
SpeedButton2->Width = 25;
SpeedButton2->Top = SpeedButton1->Top;
SpeedButton2->Left = SpeedButton1->Left +SpeedButton1->Width;
SpeedButton2->Flat= SpeedButton1->Flat;
SpeedButton2->Glyph->LoadFromFile("C:\\Documents and Settings\\Administrator\\桌面\\bmp\\-.bmp");
TSpeedButton *SpeedButton3 = new TSpeedButton(this);
SpeedButton3->Parent = this;
SpeedButton3->Height= 25;
SpeedButton3->Width = 25;
SpeedButton3->Top = SpeedButton1->Top;
SpeedButton3->Left = SpeedButton2->Left +SpeedButton2->Width;
SpeedButton3->Flat= SpeedButton1->Flat;
SpeedButton3->Glyph->LoadFromFile("C:\\Documents and Settings\\Administrator\\桌面\\bmp\\P.bmp");
this->Height = 80;
this->Width = 210;
this->Color =clWhite;
this->Caption = " ";
}
//---------------------------------------------------------------------------
namespace Mypanel
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TMyPanel)};
RegisterComponents("Standard", classes, 0);
}
}
//---------------------------------------------------------------------------
我这样继承Panel,里面放上几个控件,怎样把控的属性和事件开放出来啊?
主要是把Image的Picture,Label的Captionn属性和Button的Oclick事件