Autor Beitrag
bockwurst
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 191

win98 /XP
D1 D5 Prof DE2005PE
BeitragVerfasst: Mi 18.04.07 16:11 
Um einen doppleten Programmstart zuverhindern habe ich die Komponente TApplicationEvents (unit AppEvents) benutzt. Das klappt alles ganz wunderbar.

Nun aber!

Meine BDE Exception-Meldungen (auch TSession usw..) werden jetzt allerdings nicht mehr auf dem Bildschirm gezeigt. Wie kann ich dies ändern?



Es geht aber auch anders (nicht)!
ich habe ganz neue Anwendung mit einer HauptForm. In Form.create gebe ich 2 Zeilen Code ein.

Session.Addpassword('XXXX');
Session.NetfileDir('sdsdsd');

ich starte nun dieses Programm und es kommt eine Fehlermeldung (Fehler beim Init..) & "Falscher Pfad".

nun benutze ich TApplicationEvent und es kommt keine Fehlermeldung mehr.
Nun lösche ich noch meine Komponente. Und es kommt wieder keine Meldung. erst wenn ich in Uses die Unit AppEvnts lösche kommen wieder meine Meldungen

Andreas
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mi 18.04.07 17:00 
Um doppelten App-Start zu verhindern, kann man auch einfach einen Mutex kreieren :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  CreateMutex(nil, false, 'MyAppName'); // schlägt fehl, wenn es den "named mutex" schon gibt
  If GetLastError = ERROR_ALREADY_EXISTS then begin
    ShowMessage('Program already running');
    Halt(0);
  end;
  Application.Initialize;
...

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
bockwurst Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 191

win98 /XP
D1 D5 Prof DE2005PE
BeitragVerfasst: Do 19.04.07 08:35 
Vielen Dank HelgeLange,
habe nun aber meinen Fehler gefunden. Ich muß in TApplicationEvents in den Ereignissen ein in OnExecpetion MessageDlg einbauen.

Trotzdem möchte es es wie Du machen.
Alledings wäre es schon, wenn keine Meldung kommen würde (Programm already..), sondern ein gleich das (vorher geöffnete) Programm vorne auf den Bildschirm kommt. Dies geht mit

Application.restore;
SetForegroundWindow(Handle);
SetActiveWindow(Handle);

Nun fehlt mir aber der Handle.

Wie kann ich ihne bekommen und muß ich ein ReleaseMutex am Ende des Programms haben?

Andreas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 21.04.07 20:03 
@Helge: CreateMutex liefert ein Handle auf ein HMUTEX zurück, welches beim Programm-Ende wieder mit CloseHandle geschlossen werden sollte. Daher sollte der Rückkgabewert auf jeden Fall abgefangen werden ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Sa 21.04.07 22:47 
BenBE: so ist das, wenn man es mal schnell schreibt ;)

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 21.04.07 23:56 
Wie willst Du die 10:90-Ratio verbessern, wenn Du's andren selber nicht besser zeigst ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.