AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Fenster mit bestimmten Titel automatisch schließen
Thema durchsuchen
Ansicht
Themen-Optionen

Fenster mit bestimmten Titel automatisch schließen

Ein Thema von Monsta3 · begonnen am 22. Jan 2005 · letzter Beitrag vom 22. Jan 2005
Antwort Antwort
Monsta3

Registriert seit: 11. Dez 2004
16 Beiträge
 
#1

Re: Fenster mit bestimmten Titel automatisch schließen

  Alt 22. Jan 2005, 16:25
Hab ich bei SwissDelphiCenter gefunden. Ist von Thomas Stutz.

Delphi-Quellcode:
{
  FindWindowByTitle returns the handle of a window that
  contains a certain "WindowTitle".

  FindWindowByTitle gibt das Handle jenes Fensters zurück,
  das im Titel den String "WindowTitle" enthält.
}


function FindWindowByTitle(WindowTitle: string): Hwnd;
var
  NextHandle: Hwnd;
  NextTitle: array[0..260] of char;
begin
  // Get the first window
  NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
  while NextHandle > 0 do
  begin
    // retrieve its text
    GetWindowText(NextHandle, NextTitle, 255);
    if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
    begin
      Result := NextHandle;
      Exit;
    end
    else
      // Get the next window
      NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
  end;
  Result := 0;
end;

{
  Example how to search for a window that contains the
  word "notepad" and maximize it.

  Beispiel, wie man ein Fenster "notepad" findet
  und es anschliessend maximiert.
}


procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
begin
  h := FindWindowByTitle('notepad');
  if h <> 0 then // if we found notepad
    ShowWindow(h, SW_MAXIMIZE)
  else
    ShowMessage('not found.');
end;
http://www.swissdelphicenter.ch/de/showcode.php?id=327
  Mit Zitat antworten Zitat
Antwort Antwort


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:35 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