Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 01.04.03 19:37 
Hallo !!

Wie kann ich Close Messages, die zu meinem Prog geschickt werden abfangen ??

Also konkret geht es darum: ich habe ein Prog. Klar. Wenn jetzt jemand per X-Spy oder so das Handle einer eingebauten TWebbrowser kompo rausbekommt und diese schliesst, schmiert das komplette Prog ab.

Wie kann ich das denn verhindern ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 01.04.03 19:51 
Mit dem Ereignis Application.OnMessage wird man über alle eintreffenden Messages informiert...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 01.04.03 21:07 
ja nett, aber wie kann ich da überprüfen, ob ein close an den Webbrowser oder eine andre kompo die ein handle hat geschickt wird und die message dann "eliminieren" ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 02.04.03 07:46 
Die Message im OnMessage-Ereignis ist kein normaler Record, wie er in der WndProc eines TWinControl-Objekts auftaucht, sondern enthält noch mehr Informationen, nämlich an welches Fenster die Message gerichtet ist (also das Fenster-Handle). Mit Hilfe des Parameters "Handled" kannst du nun angeben, ob du die Message bereits verarbeitet hast oder nicht...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 02.04.03 14:47 
also ich hab mich jetzt mal damit gespielt, komm aber nicht zurande damit.
irgendwie steh ich total aufm schlauch !!! :autsch:

kannste mal ein beispiel posten, dass halt verhindert, dass kompos geschossen werden können ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 02.04.03 15:45 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (Msg.message = WM_CLOSE) and (Msg.hwnd = Button2.Handle) then
    Handled := True;
end;

Das funktioniert allerdings nur, wenn die Nachricht per PostMessage übermittelt wurde. Messages die mit SendMessage verschickt werden werden direkt an die jeweilige WndProc geleitet und landen daher nicht in der allgemeinen Message-Queue. Um alle Nachrichten zu erhalten, die in der WndProc eines Fensters landen musst du die WndProc subclassen.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.04.03 18:10 
also danke erstmal für den code. jetzt weiss ich auch, wo bei mir der fehler lag.

trotzdem noch ne Frage am rande: kann man denn auch per SendMessage (das ja direkt durchgeht) ein WM_CLOSE schicken ??

worin besteht denn eigendlich der unterschied zwischen SEND und POST ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 03.04.03 18:29 
matze hat folgendes geschrieben:
worin besteht denn eigendlich der unterschied zwischen SEND und POST ??

PostMessage legt die Nachricht nur in der Message-Queue ab und kehrt sofort wieder zum aufrufenden Thread zurück. SendMessage hingegen übergibt die Nachricht sofort an die zuständige Window-Procedure und kehrt erst wieder zurück wenn die WndProc die Message vollständig abgearbeitet hat. Aus diesem Grund kann ein Thread, der SendMessage verwendet auch "hängenbleiben", denn wenn per SendMessage eine Message an ein Fenster sendet dessen WndProc "hängen geblieben" ist, dann wartet dieser Thread ewig auf sein Ergebnis des SendMessage-Aufrufs.

Zitat:
trotzdem noch ne Frage am rande: kann man denn auch per SendMessage (das ja direkt durchgeht) ein WM_CLOSE schicken ??

Ja. Du kannst alle Nachrichten, die du per PostMessage verschicken kannst auch per SendMessage verschicken.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 04.04.03 15:43 
also kann ich gegen SednMessage nix machen ???? du hast was von subclassen gesagt. wie geht denn das ?
(ich kenn mich bei der API Programmiereung null aus.)

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 04.04.03 16:25 
matze hat folgendes geschrieben:
also kann ich gegen SednMessage nix machen ???? du hast was von subclassen gesagt. wie geht denn das ?
(ich kenn mich bei der API Programmiereung null aus.)

Gegen SendMessage hilft wie bereits gesagt (und wie du auch gemerkt hast ;) ) nur Subclassen.. wie das geht findest du in einem von Luckies vielen Tutorials! 8)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 04.04.03 18:21 
matze hat folgendes geschrieben:
Also konkret geht es darum: ich habe ein Prog. Klar. Wenn jetzt jemand per X-Spy oder so das Handle einer eingebauten TWebbrowser kompo rausbekommt und diese schliesst, schmiert das komplette Prog ab.

Da gegen würde ich gar nichts machen. Wer so was macht ist selber schuld und muß damit rechnen, dass das Programm abstürzt oder sonstwie unkontrollierbar reagiert.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 04.04.03 19:58 
Luckie hat folgendes geschrieben:
matze hat folgendes geschrieben:
Also konkret geht es darum: ich habe ein Prog. Klar. Wenn jetzt jemand per X-Spy oder so das Handle einer eingebauten TWebbrowser kompo rausbekommt und diese schliesst, schmiert das komplette Prog ab.

Da gegen würde ich gar nichts machen. Wer so was macht ist selber schuld und muß damit rechnen, dass das Programm abstürzt oder sonstwie unkontrollierbar reagiert.

Womit Luckie eigentlich gar nicht so unrecht hat...! :roll:

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 05.04.03 11:45 
stimmt, da habt ihr auch wieder recht !!!

danke @ all !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Do 29.05.03 18:05 
bei mir kommt jedesmal noch ein ondestroy. bei dem Ereignis kannst du ja ne neue Instanz erstellen o.ä. machen