⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clientunit1.pas

📁 Delphi 7组件与分布式应用开发源码,介绍了基础的组件应用实例
💻 PAS
字号:
unit ClientUnit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, corba, IQTest_c, IQTest_i;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    RadioGroup1: TRadioGroup;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label3: TLabel;
    Timer1: TTimer;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    QuestionNo : integer;    //    题号
    CorrectNumber : Integer; //    答对个数
    Answer : integer;        //    答案
    Useseconds :integer;              //用时
   protected
   { protected declarations }
    // 声明CORBA接口变量
    ClientVar : IIQTest;
    //CORBA初始化
    procedure InitCorba;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.InitCorba;
begin
  CorbaInitialize;
  //绑定CORBA服务器
  ClientVar := TIIQTestHelper.bind;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    Answer :=0;
    // 取答案
    if RadioButton1.Checked = true then
       Answer := 1
    else if RadioButton2.Checked = true then
       Answer := 2
    else if RadioButton3.Checked = true then
       Answer := 3;
    //如果没选择答案,则提示
    if  Answer = 0 then
      messagebox(0,' 请选择一个答案! ', ' 错误 ', MB_OK)
    else
    //显示下一题信息
    begin
      ClientVar.Check(QuestionNo, Answer);   //调用Corba服务器函数,检查结果

      QuestionNo :=QuestionNo + 1;
      Button1.enabled :=false;
      Label2.Caption :='1, 1, 2, 3, 5, __';
      Label3.Caption :='2.';
      RadioButton1.Caption :='A. 5';
      RadioButton1.Checked :=false;
      RadioButton2.Caption :='B. 7';
      RadioButton2.Checked :=false;
      RadioButton3.Caption :='C. 8';
      RadioButton3.Checked :=false;
    end;
    //messagebox(0,inttostr(Answer), ' 错误 ', MB_OK);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    InitCorba;
    QuestionNo :=1;
    Useseconds :=0;
    Label4.Caption :='00:00:00';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Answer:= 0 ;
  Timer1.Enabled :=false;
  if RadioButton1.Checked = true then
       Answer := 1
    else if RadioButton2.Checked = true then
       Answer := 2
    else if RadioButton3.Checked = true then
       Answer := 3;
  if  Answer = 0 then
      messagebox(0,' 请选择一个答案! ', ' 错误 ', MB_OK)
  else
  begin
      ClientVar.Check(QuestionNo, Answer);    //调用Corba服务器函数,检查答案
      CorrectNumber := ClientVar.Score;       ////调用Corba服务器函数,取结果
  end;

  ShowMessage('您一共答对' + inttostr(CorrectNumber) + '道题');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
    Application.Terminate;

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
    Useseconds :=Useseconds + 1;
    Label4.Caption := '用时 ' +inttostr(Useseconds) + ' 秒';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -