Thema: Delphi andere app verstecken

Einzelnen Beitrag anzeigen

Benutzerbild von fkerber
fkerber
(CodeLib-Manager)

Registriert seit: 9. Jul 2003
Ort: Ensdorf
6.723 Beiträge
 
Delphi XE Professional
 
#4

Re: andere app verstecken

  Alt 17. Aug 2004, 10:58
Hi!

Hier mal meine Anwendung für WinAmp:

Delphi-Quellcode:
procedure TForm1.WinAmp1Click(Sender: TObject);
var
  hHandle: THandle;
  str: string;
  i: integer;
  LPARRAM : DWord;
begin
  EnumWindows (@EnumWindowsProc,Integer(@LPARRAM));
  for i:=0 to Listbox1.Items.count-1 do begin
    hHandle := FindWindow(nil, PChar(Listbox1.Items[i]));
    str:=gettext(hhandle);
    if pos('Playlist', str)<> 0 then
      begin amphandle:=hhandle;
        break;
      end;
  end;

  if WinAmp1.Checked then
    begin
      ShowWindow(GetWindow(amphandle,GW_OWNER),SW_MINIMIZE);
      ShowWindow(GetWindow(amphandle,GW_OWNER),SW_HIDE);
      Winamp1.Checked:=false
    end
  else
    begin
      ShowWindow(GetWindow(amphandle,GW_OWNER),SW_SHOW);
      ShowWindow(GetWindow(amphandle,GW_OWNER),SW_MAXIMIZE);
      Winamp1.Checked:=true;
    end;
end;
EnumWindowsProc:
Delphi-Quellcode:
function EnumWindowsProc(const hWnd : Longword; Param: lParam): LongBool; stdcall;
var
  Buffer: array[0..1024] of Char;
begin
  Result := True;
  GetWindowText(hWnd, Buffer, sizeof(Buffer));
  if lstrlen(Buffer) = 0 then
   begin
    exit;
   end
  else
   begin
    Form1.listbox1.items.Add (buffer);
   end;
end;
GetText:
Delphi-Quellcode:
function GetText(Wnd: HWND): string;
var
  textlength: Integer;
  Text: PChar;
begin
  textlength := SendMessage(Wnd, WM_GETTEXTLENGTH, 0, 0);
  if textlength = 0 then Result := ''
  else
  begin
    GetMem(Text, textlength + 1);
// Änderung ->
    if Assigned(Text) then
    try
      SendMessage(Wnd, WM_GETTEXT, textlength + 1, Integer(Text));
// Result := Text;
// Änderung ->
    SetString(Result, Text, lstrlen(Text));
    finally
      FreeMem(Text);
    end;
  end;
end;
Ich hoffe, das war alles.


Ciao Frederic
Frederic Kerber
  Mit Zitat antworten Zitat