Autor Beitrag
NeWsOfTzzz
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Sa 07.08.04 20:37 
Also wenn das mit dem dxsound (s.u.) keiner weiss, dann wäre es auch ne Möglichkeit das Proggy einfach wieder aktiv zu machen also in den Vordergrund zu holen. Wie geht das ? ^^

Edit:

Also ich hab mal gesucht und das was ich hauptsächlich gefunden habe ist: Beim Aktivieren eines Fenster übergibt man den "Fokus". Das macht Windows mit der Botschaft CM_ACTIVATE. Also entweder zeigt ihr mir wie ich CM_ACTIVATE an das eigene Programm schicke oder ihr sagt mir ne Methode. Es gibt zwar Activate aber das ruft irgendwie auch nur On_Activate auf und das bringt auch nix. Anonsten hab ich tausend Methoden gefunden die einzelne Steuerelemente in den Fokus "rücken" aber nix um die ganze Anwendung zu fokussieren *heul

Moderiert von user profile iconChristian S.: Topic aus Multimedia / Spiele / Grafik verschoben am Sun 08.08.2004 um 01:40
Moderiert von user profile iconUdontknow:  Beiträge zusammengefasst.
Matthias-K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271

Win95, Win98, Win2000, WinXP, Linux
D2, D4 Client/Server, D5 Enterprise, D6 Enterprise, D7 Enterprise, Delphi2005, C/C++ 3.0, C/C ++ 5.0, C/C++ 6.0
BeitragVerfasst: So 08.08.04 02:32 
NeWsOfTzzz hat folgendes geschrieben:
Also entweder zeigt ihr mir wie ich CM_ACTIVATE an das eigene Programm schicke oder ihr sagt mir ne Methode.


wir sind hier nicht verpflichtet, dir etwas zu zeigen, oder auch sonst irgendwas. wir wenden hier unsere freizeit auf, um fragen zu beantworten. ich würde mir wünschen, das du deine frage doch noch mal umformalierst.

weil das klingt wie: macht das gefälligst für mich.

mfg matthias
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: So 08.08.04 03:45 
ich werd gar nix umschreiben nur weil es dir nicht gefällt -.-"
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: So 08.08.04 11:15 
@NeWsOfTzzz:mit der methode wirst du hier nicht viele freunde bekommen und hilfe schon gar nicht..

_________________
si tacuisses, philosophus mansisses.
Matthias-K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271

Win95, Win98, Win2000, WinXP, Linux
D2, D4 Client/Server, D5 Enterprise, D6 Enterprise, D7 Enterprise, Delphi2005, C/C++ 3.0, C/C ++ 5.0, C/C++ 6.0
BeitragVerfasst: So 08.08.04 12:30 
NeWsOfTzzz hat folgendes geschrieben:
ich werd gar nix umschreiben nur weil es dir nicht gefällt -.-"


es geht nicht darum, ob es mir gefällt! so eine formulierung gefällt NIEMANDEM!!!

und ich sehe nicht ein, warum ich jetzt meine zeit für dein problem opferen sollte, wo du mich hier so angehst!

wenn du deine frage neu formulierst, bin ich gerne bereit, dir zu helfen.

aber nicht so!

mfg matthias
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 08.08.04 12:34 
Hallo!

Bitte bleibt beim Thema und tragt solche Sachen per PN aus.

Danke!
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Mo 09.08.04 00:38 
pfff gibt andere foren...

Edit:

Naja da ihr euch alle darüber aufgeregt habt, hab ich mich gefragt ob was wahres dran ist und hab mir das noch ein paar mal durchgelesen. Also wenn man das anders betont hat´s schon Befehls charakter, ok tut mir leid... ich wollte ja euch ja nur ein bisserl helfen und hab deswegen meine Frage schon konkretisiert auf 2 Gebiete, nämlich entweder eine Botschaft an das eigene Programm schicken oder halt irgendeine Methode sofern es soetwas überhaupt gibt. Weil ich wie schon gesagt tausende Methoden gefunden hab mit denen man sogar Fenster in den Vordergrund holen kann wenn ein Fenster drüber ist oder mit denen man Steuerelemente fokussieren kann aber nix um das Programm zu fokussieren. Das würde auf jedenfall mit dem Handle s.o. gehen. Oder halt mit irgendeiner Methode die so mega versteckt ist in der Hilfe dass ich sie nicht finde...

Moderiert von user profile iconUdontknow:  Beiträge zusammengefasst.
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 11:14 
Hi,

Du hast zwei möglichkeiten, die Message an das Fenster zu schicken:

ausblenden Quelltext
1:
SendMessage(fensterHandle, WA_ACTIVE, 0);					

oder
ausblenden Quelltext
1:
PostMessage(fensterHandle, WA_ACTIVE, 0);					


Der Unterschied ist, daß SendMessage wartet, bis das Zielfenster die Botschaft abgearbeitet hat und PostMessage nur in den Message-Queue postet.

Ich hoffe, ich konnte dir helfen

Edit:

Sorry, kleiner Fehler
ausblenden Quelltext
1:
SendMessage(fesnterHandle, WM_ACTIVATE, WA_ACTIVE, 0);					

muss es heißen

Moderiert von user profile iconUdontknow:  Beiträge zusammengefasst.
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 11:22 
also die message müsste das Programm ja an sich selber senden.
1. Wie ist das FensterHandle dann?
2. Geht das überhaupt?
3. Wenn man das so manuell macht, muss man nicht noch an das aktive Fenster eine "deactivate" Botschaft schicken oder macht Windows das schon?
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 12:04 
Du kannst durchaus Messages an dein eigenes Programm senden, nichts anderes macht auch die VCL-Bibliothek.
1. Wenn dein Form z.B. Form1 heißt dann mußt du schreiben:
ausblenden Quelltext
1:
SendMessage(Form1.Handle, WM_ACTIVATE, WA_ACTIVE, 0);					

2. Ja das geht :D
3. Da immer nur ein Fenster aktiv sein kann, sind alle anderen Fenster automatisch deaktiviert. Da brauchst du dich nicht drum zu kümmern.
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 12:41 
LOL klappt nicht, also irgendwie scheint das verflucht zu sein. Ne Fehlermeldung krieg ich nicht ( wie bei all den anderen Methoden die ich ausprobiert habe ) aber das Programm will und will einfach nicht aktiv werden :/
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 12:58 
Also wenn ich dich richtig verstanden habe, ist es so:
Sobald du ein anderes Fenster anklickst hört der Sound auf.
Wenn du dein Fenster wieder anklickst, spielt es dann weiter?
Passiert wirklich garnix, wenn du die Activate-Message schickst?
Poste doch mal den code
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 13:11 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
var
  Form1: TForm1;
  MP,HP,Zeit,Einheit:integer;


implementation

{$R *.DFM}

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
Zeit:=Zeit-1;
Einheit:=Einheit+1;
if Einheit=6 then MP:=MP+1;
if Einheit=12 then
begin MP:=MP+1; HP:=HP+1; Einheit:=0end;
if Zeit=0 then
begin SendMessage(Form1.Handle, WM_ACTIVATE, WA_ACTIVE, 0); DXWaveList1.Items[0].Play(False); dxtimer1.enabled:=false; end;
eZeit.Text:=IntToStr(Zeit);
eHP.Text:=IntToStr(HP);
eMP.Text:=IntToStr(MP);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if StrToInt(Anzahl.Text)=0 then exit;
dxtimer1.enabled:=true;
Zeit:=Zeit+(StrToInt(Anzahl.Text)*2);
Anzahl.Text:='0';
eZeit.Text:=IntToStr(Zeit);
end;



Wenn das Proggy jetzt aktiv ist kommt sound an dem Punkt(Z:18 ) und ansonsten nicht. Aber egal welche Methode ich einfüge keine macht das proggy wieder aktiv, eine Methode hab ich sogar gefunden die das Proggy in den Vordergrund schiebt aber aktiviert wird´s immer noch nicht :/

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 13:24 
Ich denke mal er kommt garnicht in die Timer-Routine rein, solange das Fenster inaktiv ist, entsprechend aktiviert er das Fenster auch nicht wieder.
Du könntest die Activate-Message aus dem OnDeactivate-Event des Forms schicken. Dann kann zwar keiner mehr das Aktive Fenster wechseln, aber soll ja auch keiner :D
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 13:39 
Doch der Timer läuft weiter (ich bin nicht blöd lol)
Ausserdem muss das Fenster gewechselt werden weil der Timer sich ja melden soll
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 13:42 
Guck mal was passiert, wenn du nach dem SendMessage ein Application.ProcessMessages aufrufst
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 13:49 
Immer noch nix :/
das ist irgendwie echt verzwickte angelegenheit, vielleicht geht´s doch net mit der message an sich selbst :(
BadDog
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 10.08.04 14:05 
Und ein Application.BringToFront anstatt SendMessage?
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Di 10.08.04 14:07 
Das ist die Methode die in den Vordergrund bringt aber nicht aktiviert lol
Naja irgendwie bringt die das jetzt auch nicht mehr in den Vordergrund, vllt. war es eine der 100 anderen methoden...
free.pages.at/michaelmueller1/Timer.rar
download mal und probier auch mal lol geht irgendwie schneller so ^^
achso brauchst delphix dafür, im übrigen ist mir aufgefallen dass der button fokussiert wird und unten das task leisten symbol blinkt...
Matthias
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 121



BeitragVerfasst: Mi 11.08.04 09:19 
Hallo,

eine Anwendung sicher in den Vordergrund zu bringen ist gar nicht so einfach. Um dieses Problem zu lösen bin ich irgend wann einmal im Web auf folgende Lösung gestoßen. Alle bisher in diesem Thread beschriebenen Methoden habe ich auch schon mal probiert und brachten keinen sicheren Erfolg.

ciao
Matthias

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
function ForceForegroundWindow(hwnd: THandle): Boolean;
const
  SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
  SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
  ForegroundThreadID: DWORD;
  ThisThreadID: DWORD;
  timeout: DWORD;
begin
  if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE);

  if GetForegroundWindow = hwnd then Result := True
  else
  begin
    // Windows 98/2000 doesn't want to foreground a window when some other
    // window has keyboard focus

    if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or
      ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
      ((Win32MajorVersion > 4or ((Win32MajorVersion = 4and
      (Win32MinorVersion > 0)))) then
    begin
      // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
      // Converted to Delphi by Ray Lischner
      // Published in The Delphi Magazine 55, page 16

      Result := False;
      ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow, nil);
      ThisThreadID := GetWindowThreadPRocessId(hwnd, nil);
      if AttachThreadInput(ThisThreadID, ForegroundThreadID, True) then
      begin
        BringWindowToTop(hwnd); // IE 5.5 related hack
        SetForegroundWindow(hwnd);
        AttachThreadInput(ThisThreadID, ForegroundThreadID, False);
        Result := (GetForegroundWindow = hwnd);
      end;
      if not Result then
      begin
        // Code by Daniel P. Stasinski
        SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0),
          SPIF_SENDCHANGE);
        BringWindowToTop(hwnd); // IE 5.5 related hack
        SetForegroundWindow(hWnd);
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);
      end;
    end
    else
    begin
      BringWindowToTop(hwnd); // IE 5.5 related hack
      SetForegroundWindow(hwnd);
    end;

    Result := (GetForegroundWindow = hwnd);
  end;
end{ ForceForegroundWindow }