Einzelnen Beitrag anzeigen

H3llsing

Registriert seit: 12. Nov 2008
96 Beiträge
 
Delphi 2010 Enterprise
 
#15

AW: Programmposition beim Doppelaufruf ändern?

  Alt 10. Dez 2010, 09:11
Ein Handle ist eine eindeutige Identifikationsnr, darüber lassen sich beispielsweise die fremde Fenster steuern.

also entweder die funktion die ich oben gepostet habe erweitern
hier die Funktion, hoffe das war alles



Delphi-Quellcode:
 type
  TwndHandle = record
    Handle :LongWord;
    title :string;
  end;

...

FUNCTION TfrmMain.getMyHandle: TwndHandle;
VAR
  Param: TMyEnumParam;
  I: Integer;
  myhandle : Cardinal;
  wndHandle : TwndHandle;

  function GetWindows(const hWnd : Longword; Param: PMyEnumParam): LongBool; stdcall;
var
  Len : Longint;
  S : String;
begin
  Result := True;
  if not ( IsWindow(hWnd) and IsWindowVisible(hWnd) ) then Exit;
  Len := SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
  if Len > 0 then
  begin
    SetLength(S, Len);
    SendMessage(hWnd, WM_GETTEXT, Len + 1, Longint(Pchar(S)));
    Param.lb.Items.Add(Inttostr(hwnd) + '; ' + s);
  end;
  // mit Result = False kann die Callbackfunktion vorzeitig verlassen werden
end;

BEGIN

  ListBox1.Items.Clear;
  Param.lb := Listbox1;
  Listbox1.Items.clear;
  EnumWindows(@GetWindows, LPARAM(@Param));
  wndHandle.Handle := 0;
  wndHandle.title := 'false';


  //Fenster aus Taskleiste anzeigen
  FOR I := 0 TO ListBox1.Items.Count - 1 DO
  BEGIN
    IF Pos('Fenstername', Trim(AnsiUppercase(ListBox1.Items.Strings[i]))) > 0 THEN
        begin
      myHandle := StrtoInt(Copy(ListBox1.Items.Strings[i], 1, pos(';', ListBox1.Items.Strings[i]) - 1));
      ShowWindow(myhandle,SW_SHOWNORMAL);
      wndHandle.Handle := myHandle;
      wndHandle.title := 'minimiert';
      break;
    end;
  END;

  //Anmeldungsfenster zurückgeben
  FOR I := 0 TO ListBox1.Items.Count - 1 DO
  BEGIN
    //ANMELDUNG ist hier der Fenstername der gesucht wird
    IF Pos('ANMELDUNG', Trim(AnsiUppercase(ListBox1.Items.Strings[i]))) > 0 THEN
    begin
      myHandle := StrtoInt(Copy(ListBox1.Items.Strings[i], 1, pos(';', ListBox1.Items.Strings[i]) - 1));
      wndHandle.Handle := myHandle;
      wndHandle.title := Copy(ListBox1.Items.Strings[i], pos(';', ListBox1.Items.Strings[i]) + 1,length(ListBox1.Items.Strings[i]));
      break;
    end;
  END;

  result := wndHandle;


END;

oder hier zum selber basteln
http://www.delphipraxis.net/745-das-...ausfinden.html
  Mit Zitat antworten Zitat