Einzelnen Beitrag anzeigen

nahpets
(Gast)

n/a Beiträge
 
#7

Re: procedure nach Application.run

  Alt 17. Sep 2009, 12:26
Hallo,
Zitat von Bomberbb:
Und Application.run soll in meinem Fall immer ausgeführt werden. Nur hab ich leider keine Procedure gefunden, die bei Application.run ausgeführt wird, wenn Application.ShowMainForm false ist.
wüsste nicht, das es die gibt.

Meiner Meinung nach musst Du vor dem Application.Run "nur" sicherstellen, dass das von Dir gewünschte Formular angezeigt wird.

Okay, habe mal ein bisserl rumgedaddelt, mit den bisherigen Vorschlägen ist Dein Wunsch nicht umzusetzen, deshalb mal folgender Ansatz:

dpr
Delphi-Quellcode:
program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas{Hauptformular},
  Unit2 in 'Unit2.pas{Nebenformular};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(THauptformular, Hauptformular);
  Application.CreateForm(TNebenformular, Nebenformular);
  If ParamStr(1) = 'openthen begin
    Application.MainForm.WindowState := wsMinimized;
    NebenFormular.ShowModal;
  end;
  Application.Run;
end.
Hauptformular
Delphi-Quellcode:
unit Unit1;

interface

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

type
  THauptformular = class(TForm)
    procedure FormActivate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Hauptformular: THauptformular;

implementation

{$R *.dfm}

procedure THauptformular.FormActivate(Sender: TObject);
begin
  If ParamStr(1) = 'openthen begin
    Hauptformular.WindowState := wsMinimized;
  end;
end;

end.
Nebenformular
Delphi-Quellcode:
unit Unit2;

interface

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

type
  TNebenformular = class(TForm)
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Nebenformular: TNebenformular;

implementation

{$R *.dfm}

procedure TNebenformular.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  If ParamStr(1) = 'openthen begin
    Close;
    Application.MainForm.Close;
  end;
end;

end.
Eventuell hilft das ja weiter.
  Mit Zitat antworten Zitat