AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Das Programm einmal Starten. Beispiel.
Thema durchsuchen
Ansicht
Themen-Optionen

Das Programm einmal Starten. Beispiel.

Ein Thema von Karstadt · begonnen am 27. Jan 2006 · letzter Beitrag vom 26. Jul 2006
 
Karstadt

Registriert seit: 8. Nov 2005
788 Beiträge
 
#1

Das Programm einmal Starten. Beispiel.

  Alt 27. Jan 2006, 20:06
Delphi-Quellcode:
program Project1;

uses
  Forms, Windows,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}

var hPrevWin: HWND;

begin
  Application.Initialize;
  
  hPrevWin := FindWindow('TForm1', 'Form1');

  If hPrevWin <> 0 Then
  begin
     SetForegroundWindow(hPrevWin);
     Application.terminate;
  end;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

So wird der Doppeltstart verhindert, außerdem wird beim 2start das Programm nach vornge gesetz.
Funktioniert aber nicht, wenn das Programm minimiert ist.

Sonst ist das funktionsfähig!

Was mir noch nicht so gefällt ist, das beim zweiten start ich das "FORM1" kurzfristig sehen kann, kann man das irgendwie verhindern?


bzw. ist das so richtig?

Delphi-Quellcode:
program Project1;

uses
  Forms, Windows,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}

var hPrevWin: HWND;

begin
  hPrevWin := FindWindow('TForm1', 'Form1');
  If hPrevWin <> 0 Then
  begin
     SetForegroundWindow(hPrevWin);
     Application.terminate;
  end
  else
  begin
    Application.Initialize;
    Application.CreateForm(TForm1, Form1);
    Application.Run;
  end;
end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz