Autor Beitrag
Maatin
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mo 17.06.02 18:46 
Moin,

den FAQ-Eintrag zum Doppelstart von Programmen habe ich bereits gelesen und ausprobiert - klappt soweit.
Nur was mache ich, wenn ich statt sang- und klanglos nichts zu tun, lieber eine Fehlermeldung ausgeben will oder noch besser: Das bereits aktive Programm in den Vordergrund holen moechte?

danke,
gruss, Maatin
DieHardMan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 17.06.02 19:19 
ja da machst du einfach

ausblenden Quelltext
1:
2:
3:
4:
5:
  if GetLastError=ERROR_ALREADY_EXISTS then
  begin
    showmessage('Pech ghabt, läuft scho!');
    Halt;
  end;


dann wegen in den Vordergrund holen

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
  if GetLastError=ERROR_ALREADY_EXISTS then
  begin
    h := findwindowbytitle('fenstername deines programmes');
    setforeground(h);
    Halt;
  end;


die API setforeground wird glaub anders aufgerufen, musst nachschauen.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
function FindWindowByTitle(WindowTitle: String): Hwnd;
var
  NextHandle: HWND;
  NextTitle: array[0..255] of Char;
begin
  NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
  while NextHandle > 0 do
  begin
    GetWindowText(NextHandle, NextTitle, 255);
    if pos(WindowTitle, StrPas(NextTitle)) <> 0 then
    begin
      Result := NextHandle;
      Exit;
    end
    else
      NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
    end;
  Result := 0;
end;

_________________
Mahlzeit
Maatin Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Di 18.06.02 10:18 
Moin,

danke, klappt super :)

SetForeGroundWindow(Hwnd); ist uebrigens der Aufruf ...

gruss, Maatin
Burgpflanze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67

Windows2000 Prof. SP4
Delphi7 Enterprise
BeitragVerfasst: Do 25.07.02 02:35 
Noch besser so:

ausblenden Quelltext
1:
2:
3:
 
if IsIconic(Handle) then ShowWindow(Handle, SW_RESTORE)
else SetForegroundWindow(Handle);




Gruss
Burgpflanze

_________________
Gruss, Burgpflanze
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 25.07.02 08:35 
Die Abfrage
ausblenden Quelltext
1:
if IsIconic(Handle) then					

kann man sich auch sparen.