Einzelnen Beitrag anzeigen

thomas49

Registriert seit: 1. Mär 2010
3 Beiträge
 
#1

CoolTrayIcon + Fenster der ersten Instanz anzeigen geht nich

  Alt 10. Mär 2010, 13:15
Ich habe da ein Problem und hoffe Ihr könnt mir helfen.
Da dies meine erste Anfrage hier ist, hoffe ich die richtige Rubrik gewählt zu haben.


Exemplarisch habe ich mal ein abgespeckten Quellcode angehängt.
Dazu verwende ich noch die bekannte CoolTryIcon Komponente.
http://subsimple.com/delphi.asp

Ich verwende Diese, weil mein Delphi 5 das selbst noch nicht hergibt.
Des Weiteren habe ich noch das TadpInstanceControl

http://delphi.about.com/library/weekly/aa110203a.htm
eingebunden. Das sorgt dafür, das immer nur eine vorgebende Anzahl von Instanzen gestartet werden kann. Kann man zwar auch händisch (Mutex) einbauen, ich habe mich jedoch für die Variante entschieden.

Ich möchte jetzt, dass wenn mein Fenster in den Tray verschwindet ein weiterer Start des Programms das Fenster wieder in den Vordergrund holt.
Mein Programm bekommt zwar den Start einer weitern Instanz mit, das Meldungsfenster erscheint, aber der nachfolgende Befehl „trayIcon1.ShowMainForm“ zeigt keine Wirkung.
Laut CooltrayIcon Doku sollte auch nur dieser Befehl verwendet werden, um das Fenster wieder zu Zeigen.

Meine Status ist Programmieranfänger. Ich verwende Delphi 5 und Win 7 Prof 64 Bit.

Danke schon mal für eure Tipps.

Gruß Thomas

Delphi-Quellcode:
{  Delphi 5

Enthält
- CooltrayIcon : [url]http://subsimple.com/delphi.asp[/url]


- TadpInstanceControl

Full source code of a Delphi component that can
control the behavior of your application's multiple instances:
with the option to limit the number of running instances.
Part 2 of the "Controlling the number of application instances" article.

URL:

1) [url]http://delphi.about.com/library/weekly/aa110203a.htm[/url]
2) [url]http://delphi.about.com/library/weekly/aa100703a.htm[/url]


..............................................
Zarko Gajic, BSCS
About Guide to Delphi Programming
[url]http://delphi.about.com[/url]
how to advertise: [url]http://delphi.about.com/library/bladvertise.htm[/url]
free newsletter: [url]http://delphi.about.com/library/blnewsletter.htm[/url]
forum: [url]http://forums.about.com/ab-delphi/start/[/url]
..............................................
}



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, CoolTrayIcon, adpInstanceControl;

type
  TForm1 = class(TForm)
    TrayIcon1: TCoolTrayIcon;
    Button1: TButton;
    adpInstanceControl1: TadpInstanceControl;
    procedure Button1Click(Sender: TObject);
    procedure TrayIcon1Click(Sender: TObject);
    procedure adpInstanceControl1MaxInstancesReached(Sender: TObject;
      const LastInstanceHandle: Cardinal);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
trayicon1.hideMainForm;
end;

procedure TForm1.TrayIcon1Click(Sender: TObject);
begin
trayicon1.ShowMainForm;
end;

procedure TForm1.adpInstanceControl1MaxInstancesReached(Sender: TObject;
  const LastInstanceHandle: Cardinal);
begin
showmessage('Zeige wieder das Fenster der ersten Instanz..');

trayIcon1.ShowMainForm; //Das funktioniert leider nicht.
PostMessage(TrayIcon1.Handle, WM_TRAYNOTIFY, Integer(TrayIcon1), WM_LBUTTONDOWN); //auch nicht.
end;


end.
Angehängte Dateien
Dateityp: zip trayicononeinstance_187.zip (8,6 KB, 4x aufgerufen)
  Mit Zitat antworten Zitat