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

📄 unit1.pas

📁 Directx游戏制作开发包DGCBETA6
💻 PAS
字号:
{
  Multiple Forms with DirectDraw's Full Screen Mode
  -----------------------------------------------------------------------
  This demo shows how to bring back the Windows screen so that you can
  process dialogs if you need. This demo captures the screen resolution
  and when the user presses 's' the DirectDraw screen will minimize and
  Windows will be brought back. At this point, you can show any Forms that
  you may need to gather info from the user, ie. connection information for
  DirectPlay games, capture exception errors, etc.

  Once the player is ready to return back to the game, the DirectDraw screen
  is shown and the game continues. Note: You must turn page flipping off
  before going back to Windows and you can turn it back on when you return
  back to your game. Also, you should redraw the game screen before
  continuing the game.
}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DGC, DGCStar;

type
  TForm1 = class(TForm)
    DGCScreen1: TDGCScreen;
    DGCStarField1: TDGCStarField;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure DGCScreen1Flip(Sender: TObject);
    procedure DGCScreen1Initialize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  TextXPos : Integer;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  If Key = #27 then Close;
  if (key = 's') or (key = 'S') then
  begin
     // Stop page flipping
     DGCScreen1.FlippingEnabled := False;
     // Minimize the DirectDraw Screen
     Form1.WindowState := wsMinimized;
     // Hide it from view so the user can't click on it
     Form1.Hide;
     // Show the screen cursor
     Screen.Cursor := crDefault;
     // Change screen mode back to starting resolution
     DGCScreen1.DirectDraw2.RestoreDisplayMode;
     Application.ProcessMessages;
     // Show the second form and wait
     Form2.ShowModal;
     // Unhide Form1 -- Direct Draw Screen
     Form1.Show;
     // Turn cursor off
     Screen.Cursor := crNone;
     // Change resolution back to the game resolution
     DGCScreen1.DirectDraw2.SetDisplayMode(640,400,8);
     Application.ProcessMessages;
     // Show the DirectDraw Screen
     Form1.WindowState := wsMaximized;
     // Erase screens (may be some left over garbage)
     DGCScreen1.Back.Erase(0);
     DGCScreen1.Front.Erase(0);
     // Turn page flipping back on
     DGCScreen1.FlippingEnabled := True;

  end;
end;

procedure TForm1.DGCScreen1Flip(Sender: TObject);
begin
  DGCStarfield1.Update;
  With DGCScreen1.Back.Canvas do
  begin
    Dec(TextXPos,1);
    If TextXPos < -600 then TextXPos := 644;
    TextOut(TextXPos,180,'PRESS [S] to Switch back to Windows!');
    Release;
  end;
end;

procedure TForm1.DGCScreen1Initialize(Sender: TObject);
begin
   DGCStarfield1.Generate;
   With DGCScreen1.Back.Canvas do
   begin
      Font.Color := clWhite;
      Font.Size := 24;
      Brush.Style := bsClear;
      TextXPos := 650;
      Release;
   end;
end;

end.

⌨️ 快捷键说明

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