人
人在边缘
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是Demo的源代码:至于具体窗体设计,你可以参照Demo样式。
Setup.pas (这是setup设置窗口的代码,即主窗体)
unit Setup;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TfrmSetup = class(TForm)
cmbRes: TComboBox;
Resolution: TLabel;
cbFullscreen: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
rb16: TRadioButton;
rb32: TRadioButton;
procedure btnCancelClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure cbFullscreenClick(Sender: TObject);
procedure cmbResChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure rb16Click(Sender: TObject);
procedure rb32Click(Sender: TObject);
private
{ Private declarations }
public
windowWidth : Integer;
windowHeight : Integer;
windowColorDepth : Integer;
fullscreen : Boolean;
closeProgram : Boolean;
end;
var
frmSetup: TfrmSetup;
implementation
{$R *.DFM}
procedure TfrmSetup.btnCancelClick(Sender: TObject);
begin
closeProgram := True;
Close;
end;
procedure TfrmSetup.btnOKClick(Sender: TObject);
begin
Close;
end;
procedure TfrmSetup.cbFullscreenClick(Sender: TObject);
begin
fullscreen := not fullscreen;
cmbRes.Enabled := fullscreen;
rb16.Enabled := fullscreen;
rb32.Enabled := fullscreen;
end;
procedure TfrmSetup.cmbResChange(Sender: TObject);
begin
case cmbRes.ItemIndex of
0 : // 640x480
begin
windowWidth := 640;
windowHeight := 480;
end;
1 : // 800x600
begin
windowWidth := 800;
windowHeight := 600;
end;
2 : //1024x768
begin
windowWidth := 1024;
windowHeight := 768;
end;
3 : // 1152x864
begin
windowWidth := 1152;
windowHeight := 864;
end;
4 : // 1280x960
begin
windowWidth := 1280;
windowHeight := 960;
end;
5 : // 1280x1024
begin
windowWidth := 1280;
windowHeight := 1024;
end;
end;
end;
procedure TfrmSetup.FormCreate(Sender: TObject);
begin
cmbRes.ItemIndex := 0;
windowWidth := 640;
windowHeight := 480;
windowColorDepth := 16;
fullscreen := False;
closeProgram := False;
end;
procedure TfrmSetup.rb16Click(Sender: TObject);
begin
windowColorDepth := 16;
end;
procedure TfrmSetup.rb32Click(Sender: TObject);
begin
windowColorDepth := 32;
end;
end.
Setup.pas (这是setup设置窗口的代码,即主窗体)
unit Setup;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TfrmSetup = class(TForm)
cmbRes: TComboBox;
Resolution: TLabel;
cbFullscreen: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
rb16: TRadioButton;
rb32: TRadioButton;
procedure btnCancelClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure cbFullscreenClick(Sender: TObject);
procedure cmbResChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure rb16Click(Sender: TObject);
procedure rb32Click(Sender: TObject);
private
{ Private declarations }
public
windowWidth : Integer;
windowHeight : Integer;
windowColorDepth : Integer;
fullscreen : Boolean;
closeProgram : Boolean;
end;
var
frmSetup: TfrmSetup;
implementation
{$R *.DFM}
procedure TfrmSetup.btnCancelClick(Sender: TObject);
begin
closeProgram := True;
Close;
end;
procedure TfrmSetup.btnOKClick(Sender: TObject);
begin
Close;
end;
procedure TfrmSetup.cbFullscreenClick(Sender: TObject);
begin
fullscreen := not fullscreen;
cmbRes.Enabled := fullscreen;
rb16.Enabled := fullscreen;
rb32.Enabled := fullscreen;
end;
procedure TfrmSetup.cmbResChange(Sender: TObject);
begin
case cmbRes.ItemIndex of
0 : // 640x480
begin
windowWidth := 640;
windowHeight := 480;
end;
1 : // 800x600
begin
windowWidth := 800;
windowHeight := 600;
end;
2 : //1024x768
begin
windowWidth := 1024;
windowHeight := 768;
end;
3 : // 1152x864
begin
windowWidth := 1152;
windowHeight := 864;
end;
4 : // 1280x960
begin
windowWidth := 1280;
windowHeight := 960;
end;
5 : // 1280x1024
begin
windowWidth := 1280;
windowHeight := 1024;
end;
end;
end;
procedure TfrmSetup.FormCreate(Sender: TObject);
begin
cmbRes.ItemIndex := 0;
windowWidth := 640;
windowHeight := 480;
windowColorDepth := 16;
fullscreen := False;
closeProgram := False;
end;
procedure TfrmSetup.rb16Click(Sender: TObject);
begin
windowColorDepth := 16;
end;
procedure TfrmSetup.rb32Click(Sender: TObject);
begin
windowColorDepth := 32;
end;
end.