Einzelnen Beitrag anzeigen

schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#1

SetForegroundWindow geht teilweise nicht!?

  Alt 14. Jan 2009, 19:22
Hallo,

bin momentan etwas verwirrt...

ich starte mit CreateProcess ein externes Programm:
Delphi-Quellcode:
function RunProcess(FileName: string; ShowCmd: DWORD; wait: Boolean; ProcIDRunProcess: PDWORD): TProcessInformation;
var
  StartupInfoRunProcess: TStartupInfo;
  ProcessInfoRunProcess: TProcessInformation;
  ExitInfo : PExitThreadDebugInfo;
begin
  FillChar(StartupInfoRunProcess, SizeOf(StartupInfoRunProcess), #0);
  StartupInfoRunProcess.cb := SizeOf(StartupInfoRunProcess);
  StartupInfoRunProcess.dwFlags := STARTF_RUNFULLSCREEN
      or STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
  StartupInfoRunProcess.wShowWindow := ShowCmd;


  if not CreateProcess(nil,@Filename[1],nil,nil,False,CREATE_BREAKAWAY_FROM_JOB or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,nil,nil,StartupInfoRunProcess,ProcessInfoRunProcess) then begin
  Result.hProcess := WAIT_FAILED;
  end
  else
  begin
    Result := ProcessInfoRunProcess;

    if wait = FALSE then
    begin
// if ProcIDRunProcess <> nil then ProcIDRunProcess^ := ProcessInfoRunProcess.dwProcessId;
      exit;
    end;

    WaitForSingleObject(ProcessInfoRunProcess.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfoRunProcess.hProcess, Result.hProcess);
  end;

  if ProcessInfoRunProcess.hProcess <> 0 then
    CloseHandle(ProcessInfoRunProcess.hProcess);
  if ProcessInfoRunProcess.hThread <> 0 then
    CloseHandle(ProcessInfoRunProcess.hThread);
end;
Ablauf: FremdSoftware1 gibt meiner App den Befehl für CreateProcess
Meine App öffnet dann FremdSoftware2

Die FremdSoftware2 möchte ich nun Maximized & FullScreen (keine Taskleiste sichtbar) starten.

Wenn der Ablauf nun startet ist ja zuerst FremdSoftware1 in der Taskleiste aktiv. Nun wird FremdSoftware2 gestartet und taucht auch in der Taskleiste auf. Aber aktiv bleibt FremdSoftware1.
Obwohl ich auch mit SetForegroundWindow die FremdSoftware2 im Vordergrund hole.
Bei diesem Command blinkt nur der Taskleisteneintrag von FremdSoftware2.

Wenn ich dann mit der Mouse auf den Taskleisteneintrag drücke verschwindet die Leiste und FremdSoftware2 ist im Vordergrund.

Was ist hier los?
Kann man einen Taskleistenklick per Code durchführen?
  Mit Zitat antworten Zitat