線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:669
推到 Plurk!
推到 Facebook!

做好的繼承Class如何放到元件盤上

尚未結案
renth555
一般會員


發表:32
回覆:65
積分:19
註冊:2003-02-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-03 18:45:02 IP:61.56.xxx.xxx 未訂閱
做好的繼承Class,我要如何放到元件盤上,與可顯示屬性的設定和事件的選寫 這是取至站上一篇文章做範例:    
Unit1.cpp    //---------------------------------------------------------------------------
#include 
#pragma hdrstop    #include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TButtonGroup *BG;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
   BG = new TButtonGroup(this);
   BG->Parent = Form1;
   BG->Top = 10;
   BG->Left = 10;
   BG->Width = 200;
   BG->Height = 200;
   BG->Caption = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
   delete BG;
}
//---------------------------------------------------------------------------    Unit2.cpp    //---------------------------------------------------------------------------
#include 
#pragma hdrstop    #include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
__fastcall TButtonGroup::TButtonGroup(TComponent* Owner)
   : TGroupBox(Owner)
{
//===========================================================================
// TButtonGroup 類別建構函式
//===========================================================================
   Button1 = new TButton(this);
   Button2 = new TButton(this);
   Button3 = new TButton(this);
   Button1->Parent = this;
   Button2->Parent = this;
   Button3->Parent = this;
   Button1->OnClick = OnClick;
   Button2->OnClick = OnClick;
   Button3->OnClick = OnClick;
   Button1->Height = 20;
   Button2->Height = 20;
   Button3->Height = 20;
   Button1->Width = 80;
   Button2->Width = 80;
   Button3->Width = 80;
   Button1->Top = 10;
   Button2->Top = 40;
   Button3->Top = 70;
   Button1->Left = 10;
   Button2->Left = 10;
   Button3->Left = 10;
   Button1->Caption = "Button1";
   Button2->Caption = "Button2";
   Button3->Caption = "Button3";
   Button1->Enabled = true;
   Button2->Enabled = false;
   Button3->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TButtonGroup::OnClick(TObject *Sender)
{
//===========================================================================
// TButtonGroup 類別內事件函式
//===========================================================================
   Button1->Enabled = false;
   Button2->Enabled = false;
   Button3->Enabled = false;
   if(Sender==Button1)
   Button2->Enabled = true;
   if(Sender==Button2)
   Button3->Enabled = true;
   if(Sender==Button3)
   Button1->Enabled = true;
}
//---------------------------------------------------------------------------    Unit2.h    //---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
class TButtonGroup : public TGroupBox
{
__published:
   TButton *Button1;
   TButton *Button2;
   TButton *Button3;
   void __fastcall OnClick(TObject *Sender);
private:
public:
   __fastcall TButtonGroup(TComponent* Owner);
};
//---------------------------------------------------------------------------
#endif    
markov
中階會員


發表:55
回覆:135
積分:53
註冊:2003-12-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-03 22:04:43 IP:61.229.xxx.xxx 未訂閱
你要做成VCL
renth555
一般會員


發表:32
回覆:65
積分:19
註冊:2003-02-17

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-04 10:51:11 IP:61.56.xxx.xxx 未訂閱
是的我要把他包裝成 VCL 放到元件列上
系統時間:2024-04-28 19:49:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!