Ver Mensaje Individual
  #14  
Antiguo 03-03-2020
MaxiDucoli MaxiDucoli is offline
Miembro
 
Registrado: feb 2006
Posts: 134
Reputación: 19
MaxiDucoli Va por buen camino
Cita:
Empezado por escafandra Ver Mensaje
Ok. Te presento un programita que se ejecuta maximizado mostrando un Label que dice "LOADING GAME" al arrancar. Luego Ejecuta "Notepad.exe" y se esconde. Al cerrar Notepad, el programita se termina.


Espero que esta sea la idea de lo que quieres hacer.


Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    function Execute(CommandLine: String): cardinal;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//------------------------------------------------------------------------------
// Creamos un proceso.
function TForm1.Execute(CommandLine: String): cardinal;
var
  SI: TStartupInfo;
  PI: TProcessInformation;
begin
  ZeroMemory(@SI, sizeof(TStartupInfo));
  SI.cb:= sizeof(SI);
  SI.dwFlags:= STARTF_USESHOWWINDOW or STARTF_USEPOSITION or STARTF_USESIZE;
  SI.wShowWindow:= SW_SHOW;
  Result:= 0;
  if CreateProcess(nil, PCHAR(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  begin
    WaitForInputIdle(PI.hProcess, 10000);
    Visible:= false;
    WaitForSingleObject(PI.hProcess,INFINITE);
    GetExitCodeProcess(PI.hProcess, Result);
    CloseHandle(PI.hProcess);
    CloseHandle(PI.hThread);
  end
  else
    Result:= $FFFFFFFF;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  WindowState:= wsMaximized;
  FormStyle:= fsStayOnTop;
  BorderStyle:= bsNone;
  Label1.Caption:= '"LOADING GAME"';
  Label1.Font.Size:= 30;
  Label1.Font.Style:= [fsBold];


  // Simula que tarda en cargar...
  Timer1.Interval:= 2000;  // Poner Timer1.Interval:= 1 para no esperar nada,
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  // Simula que tarda en cargar...
  Execute('Notepad.exe');

  Visible:= True;
  Label1.Caption:= 'NOS VAMOS';
  Update;
  Sleep(500);
  Close;
end;

end.


Saludos.
Muchas gracias por tomarte el tiempo que es un recurso irrecuperable.
Esta tarde, en cuanto regrese del trabajo, esto va a ser lo primero que me ponga a hacer.

La verdad es que no me puedo explicar como pudo ser algo tan sencillo y jamás imaginarlo. Ja!
Bueno están los que saben y son fuente inagotable de sabiduría y los que no aprendemos por más ganas que le echemos. 😂 🤣 😂

Te agradezco y más tarde te paso el reporte de como me fue.

Muy agradecido!
Saludos!!!!!
Responder Con Cita