|
发表于 2020-2-23 10:15:01
|
显示全部楼层
#ifndef Unit1H
#define Unit1H
#include <Classes.hpp>
#include <ComCtrls.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
class TForm1 : public TForm
{
__published:
TPageControl *PageControl1;
TTabSheet *TabSheet1;
TTabSheet *TabSheet2;
TTabSheet *TabSheet3;
TRadioButton *A1;
TRadioButton *B1;
TRadioButton *C1;
TRadioButton *A2;
TRadioButton *B2;
TRadioButton *C2;
TRadioButton *D2;
TRadioButton *E2;
void __fastcall PageControl1Change(TObject *Sender);
void __fastcall func(TObject *Sender);
public:
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
A1->Checked=true;
A2->Checked=true;
A1->Tag=1;
B1->Tag=2;
C1->Tag=3;
A2->Tag=4;
B2->Tag=5;
C2->Tag=6;
D2->Tag=7;
E2->Tag=8;
A1->OnClick=func;
B1->OnClick=func;
C1->OnClick=func;
A2->OnClick=func;
B2->OnClick=func;
C2->OnClick=func;
D2->OnClick=func;
E2->OnClick=func;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PageControl1Change(TObject *Sender)
{
if(PageControl1->ActivePageIndex==2)
{
TabSheet3->Caption=
TabSheet1->Caption.ToIntDef(0)
+TabSheet2->Caption.ToIntDef(0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::func(TObject *Sender)
{
TRadioButton * radioButton;
radioButton=( TRadioButton *)Sender;
if(!radioButton->Checked) return;
switch (radioButton->Tag)
{
case 1: TabSheet1->Caption= 10;break;
case 2: TabSheet1->Caption= 5;break;
case 3: TabSheet1->Caption= 1;break;
case 4: TabSheet2->Caption= 10;break;
case 5: TabSheet2->Caption= 7;break;
case 6: TabSheet2->Caption= 5;break;
case 7: TabSheet2->Caption= 3;break;
case 8: TabSheet2->Caption= 1;break;
}
}
|
|