AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Console in Delphiprogramm?

Ein Thema von freak4fun · begonnen am 16. Dez 2004 · letzter Beitrag vom 26. Dez 2005
 
Benutzerbild von Shaman
Shaman

Registriert seit: 2. Nov 2003
Ort: Schweiz
407 Beiträge
 
Turbo Delphi für Win32
 
#12

Re: Console in Delphiprogramm?

  Alt 17. Dez 2004, 10:26
Hallo zusammen

Ich hab mir mit Code aus dem Forum mal folgendes zusammengebastelt, um eine Konsolenanwendung innerhalb meiner Form anzuzeigen:

Delphi-Quellcode:
function RunConsoleApp(const FileName: string; const Parent: THandle): THandle;

  function EnumWindowsProc(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
  begin
    TList(lParam).Add(Pointer(hWnd));
    Result := True;
  end;

var
  SI: TStartupInfo;
  PI: TProcessInformation;
  List: TList;
  ProcessId: DWORD;
  Console: THandle;
  I: Integer;
begin
  Result:= 0;
  FillChar(SI, SizeOf(TStartupInfo), 0);
  SI.cb := SizeOf(TStartupInfo);
  SI.dwFlags := STARTF_USESHOWWINDOW;
  SI.wShowWindow := SW_HIDE;
  if CreateProcess(nil, PChar(FileName), nil, nil, False, 0, nil, nil, SI, PI) then
  try
    Console:= 0;
    List:= TList.Create;
    try
      repeat
        List.Clear;
        if EnumWindows(@EnumWindowsProc, Longint(List)) then
        begin
          for I := 0 to List.Count - 1 do
          begin
            GetWindowThreadProcessId(Longint(List.Items[I]), ProcessId);
            if PI.dwProcessId = ProcessId then
            begin
              Console:= Longint(List.Items[I]);
              Break;
            end;
          end;
        end;
      until Console <> 0;
    finally
      List.Free;
    end;
  finally
    CloseHandle(PI.hProcess);
    CloseHandle(PI.hThread);
  end;
  if Console <> 0 then
  begin
    SetParent(Console, Parent);
    SetWindowPos(Console, 0, 0, 0, 0, 0, SWP_NOSIZE or SWP_SHOWWINDOW);
    Result:= Console;
  end;
end;
Meine Frage: Wie lässt sich nun noch die Titelleiste ausblenden, damit man die Konsole nicht mehr verschieben kann?
assert(SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) and not WS_CAPTION) <> 0); geht irgendwie nicht bei Konsolen...

Gruss
Shaman
Daniel Pauli
Looking for answers from the great beyond
  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 02:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz