Einzelnen Beitrag anzeigen

Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#7

Re: doppelter Start verhindern und Prog in den Vordergrund

  Alt 20. Jan 2010, 12:21
Zitat von hoika:
Hallo,

der Befehl heisst BringWindowToFront

als Link ein bisschen c++ Code,
ist gut lesbar, sollte 1:1 in Delphi umsetzbar sein.

1


Heiko
mal aus rein persönlichen Intresse währe das richtig übersetzt?

Delphi-Quellcode:
function ForceWindowToFront(HWND : hWnd):Boolean;
var
ForegroundWindowThreadID : Dword;
WindowThreadID : DWord;
Begin
  if (hWnd = GetForegroundWindow) then
   Result := true
  else
   Begin
    ForegroundWindowThreadID := GetWindowThreadProcessId(GetForegroundWindow, nil);
    WindowThreadID := GetWindowThreadProcessId(hWnd, nil);
    if (ForegroundWindowThreadID <> WindowThreadID) then
     Begin
      AttachThreadInput(ForegroundWindowThreadID, WindowThreadID, true);
      Result := SetForegroundWindow(hWnd);
      AttachThreadInput(ForegroundWindowThreadID, WindowThreadID, false);
     end
      else
       Result := SetForegroundWindow(hWnd);
    ShowWindow(hWnd, SW_RESTORE);
  end;
end;

Edit: Ok habs mal getestet also es tut was es soll
Marcel
  Mit Zitat antworten Zitat