Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 16.07.08 22:39 
Hallo,
ich hab da eine Frage:
Wie kann ich es erreichen, das meine versteckte Form (Form1.hide) nicht durch externe Programme wieder sichtbar gemacht wird?
Ich benutze nämlich OuttaSight (www.rosafamily.org/software/oos/index.htm) und nutze da oft die Option "alle Fenster anzeigen", wodurch die gewünschte Wirkung erzeugt wird, aber die Form wird halt auch wieder angezeigt.

Jemand eine Idee?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mi 16.07.08 22:48 
Hi,

Mit sicherheit nicht der beste Vorschlag aber spätestens seit Yugos Task-Manager wissen wir ja von 0x0-Fenstern. Im Notfall könntest du eine 0x0-Form zur Main-Form machen.. :|

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Do 17.07.08 07:01 
Warum ein TForm wenn du es dann versteckst?

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 17.07.08 11:53 
user profile iconhazard999 hat folgendes geschrieben:
Warum ein TForm wenn du es dann versteckst?

Man soll das Programm zum Trayicon minimieren können und umgekehrt.
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 17.07.08 13:42 
diese funktionalität bietet CoolTrayIcon bereits
wenn du es selber schreiben willst kann du mit TForm.Show/Hide arbeiten, den taskbar-eintrag kannst du mit Showwindow(application.handle,sw_show/sw_hide) bearbeiten.
ich musste bei meinen Projekten noch die WindowProc des Mainforms überschreiben um beim minimize kein solches auszuführen sondern ein hide.

HTH Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 17.07.08 14:19 
Du hast ihn falsch verstanden/nicht alles durchgelesen :)

es geht darum, dass sein verstecktes Fenster nicht durch andere Programme visible gemacht werden können soll ;)

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 17.07.08 15:03 
user profile iconHidden hat folgendes geschrieben:
Du hast ihn falsch verstanden/nicht alles durchgelesen :)

es geht darum, dass sein verstecktes Fenster nicht durch andere Programme visible gemacht werden können soll ;)

mfG,

Genau das mein ich aber ich habe keine Ahnung wie ich das hinbekommen soll :?
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 17.07.08 15:14 
achso...sorry, war wohl nicht ganz bei der Sache :)
nur so als Idee...du könntest nen message-Handler für die message machen, mit der SW_Show gesendet wird. dort drin überprüfst du (per flag) ob der aufruf von deinem Programm aus gesendet wurde und vewirfst ggf. die Message. ist aber ziemliche Frickelei ;)

HTH Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 17.07.08 16:01 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
type
  TInterfaceForm = class(TForm)
    ...
    procedure WMShow(var Msg: TMessage) ; message SW_SHOW;
end;

procedure TInterfaceForm.WMSHOW(var Msg: TMessage);
begin
Showmessage('abc');
end;

Hab das jetzt mal so gemacht, die Nachricht wird aber beim Starten 3x angezeigt, und nachher, wenn ich die Form wieder anzeigen lasse oder per Programm anzeigen lasse kommt keine.

Was stimmt den daran nicht? Vielleicht eine andere Message?
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 17.07.08 17:17 
mhm...dann kannst dich ja mal in die messagequeue einklinken und die messages mitloggen.

hab die unit mal hier irgendwo im forum gefunden :)
einfach einbinden und in der überschriebenen WndProc z.b.per
ausblenden Delphi-Quelltext
1:
OutputDebugString(MsgCode2Text(msg.message));					

ausgeben

HTH Frank
Einloggen, um Attachments anzusehen!
_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 17.07.08 19:06 
Ok, ich glaube ich hab die richtigen Messages gefunden.
Wie kann ich jetzt aber die Messages löschen?
Also das das Anzeigen der Form verhindert wird?
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 17.07.08 19:15 
wie ich vorhin schon geschrieben habe, prüfst du auf ein flag (boolean-variable). wenn dieses gesetzt ist, verarbeitest du die message, sonst nicht. wenn du die message selber schickst (z.b. vom Trayicon) musst du nur das flag vorher setzen ;)
und nach dem verarbeiten der messsage nicht vergessen, das flag zurückzusetzen.

HTH Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 17.07.08 19:42 
Das Problem ist nur, das wenn ich nichts mache, die Form ja durch die Message angezeigt wird.
(Das override sollte das denke ich mal verhindern)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TInterfaceForm = class(TForm)
    ...
    procedure WndProc(var msg: TMessage); override;
end;

procedure TInterfaceForm.WndProc(var msg: TMessage);
begin
OutputDebugString(PCHAR(MsgCode2Text(msg.msg)));
inherited;
end;

Wie gesagt, die Form wird trotzdem angezeigt.
Ich habe noch andere Threads am Laufen, aber diese erzeugen keine Form, also dürften die nicht stören.
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 17.07.08 21:41 
indem du inherited aufrufst wird die message trotzdem verarbeitet...wo siehst du da (in deinem Code) eine Filterfunktion?

wenn dann etwa so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TInterfaceForm.WndProc(var msg: TMessage);
begin
  OutputDebugString(PCHAR(MsgCode2Text(msg.msg)));
  if not (msg.msg=WM_Forbidden) or (flag) then inherited;
end;


HTH Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Fr 18.07.08 22:22 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TInterfaceForm.WndProc(var msg: TMessage);
begin
Outputdebugstring(PCHAR(MsgCode2Text(msg.Msg)));
if not(msg.Msg=WM_SHOWWINDOW) or not (msg.Msg=WM_NCACTIVATE) or not (msg.Msg=WM_ACTIVATEAPP) or not (msg.Msg=WM_WINDOWPOSCHANGING) or not (msg.Msg=WM_WINDOWPOSCHANGED) or not (msg.Msg=WM_COMMAND) or not (msg.Msg=WM_ACTIVATE) or not (msg.Msg=WM_ACTIVATEAPP) then inherited;
end;

Also schön langsam hab ich so ziemlich alle möglichen Messages eingetragen und trotzdem wird die Form noch angezeigt :shock:
Fehler im Code oder muss ich weiter nach Messages suchen?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 18.07.08 22:45 
Hi,

Imho endet deine Abfrage immer bei true:
ausblenden Delphi-Quelltext
1:
not(msg.Msg = WM_SHOWWINDOW) or not (msg.Msg = WM_NCACTIVATE)					

ausblenden ist äquivalent zu:
1:
(msg.Msg <> WM_SHOWWINDOW) or (msg.Msg <> WM_NCACTIVATE)					

Damit ist deine Abfrage genau dann true, wenn die Nachricht entweder ungleich a oder ungleich b ist. Sprich genau dann false, wenn Msg gleich a und gleich b ist :roll:

Du willst vermutlich, dass die Abfrage true ist, wenn keiner der Vergleiche true ist. Dazu nimmst du am besten(der Übersichtlichkeit wegen):
ausblenden Delphi-Quelltext
1:
if not (msg.Msg in [a, b, c, d]) then inherited;					


wobei a, b, c und d die Elemente deiner Menge sind.

Ein bisschen Übersichtlichkeit hat schon so manchen Fehler gezeigt ;) Das gilt sowohl für das Absetzen von Codeblöcken durch zwei Leerzeichen, siehe Suche in der Entwickler-Ecke CODEFORMATIERUNG, als auch für möglichst kurze Abfragen.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Sa 19.07.08 11:36 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TInterfaceForm.WndProc(var msg: TMessage);
begin
if not (msg.Msg in [WM_SHOWWINDOW, WM_NCACTIVATE, WM_ACTIVATEAPP, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, WM_ACTIVATE, WM_ACTIVATEAPP]) then inherited;
Outputdebugstring(PCHAR(MsgCode2Text(msg.Msg)));
end;

Funktionieren wills immer noch nicht, das Fenster wird trotzdem angezeigt.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Sa 19.07.08 20:23 
Hi,

Lass dir doch einfach mal msg.Msg ausgeben und such dann nach dem Zahlencode oder was da kommt in einer Message-codelist..

die blockierst du dann.

E:
ausblenden nochmal ein Formatierungsvorschlag:
1:
2:
3:
4:
5:
6:
7:
procedure TInterfaceForm.WndProc(var msg: TMessage);
const
  BlockMessages = [WM_SHOWWINDOW, WM_NCACTIVATE, WM_ACTIVATEAPP, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, WM_ACTIVATE, WM_ACTIVATEAPP];
begin
  if not (msg.Msg in BlockMessages) then inherited;
  Outputdebugstring(PChar(MsgCode2Text(msg.Msg)));
end;


mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Di 22.07.08 14:17 
Läuft immer noch nicht.
Mein momentaner Quelltext:
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:
unit Unit3;

interface

uses
  Windows, Messages, UMsgText, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    Button1: TButton;
    procedure WndProc(var msg: TMessage); override;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.WndProc(var msg: TMessage);
begin
  if not (msg.Msg in [WM_SHOWWINDOW, WM_WINDOWPOSCHANGING]) then inherited;
  Outputdebugstring(PCHAR(MsgCode2Text(msg.Msg)));
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
  form3.Hide;
end;

end.

Die beiden Zeilen, die ausgegeben werden, wenn ich per Programm die Form anzeigen lasse:
ausblenden Quelltext
1:
Debug-Ausgabe: WM_CAP_FILE_SET_INFOCHUNK <Vfw.h> WM_SHOWWINDOW <WinUser.h> HDM_CLEARFILTER <CommCtrl.h> LVM_GETEDITCONTROL <CommCtrl.h> RB_BEGINDRAG <CommCtrl.h> TBM_GETLINESIZE <CommCtrl.h> TB_BUTTONCOUNT <CommCtrl.h> TTM_SETMAXTIPWIDTH <CommCtrl.h> Prozess Project3.exe (2988)					

ausblenden Quelltext
1:
Debug-Ausgabe: WM_CAP_SINGLE_FRAME_OPEN <Vfw.h> WM_WINDOWPOSCHANGING <WinUser.h> EM_SETOLECALLBACK <Richedit.h> ICM_COMPRESS_FRAMES_INFO <Vfw.h> LVM_GETWORKAREAS <CommCtrl.h> TB_SETDRAWTEXTFLAGS <CommCtrl.h> Prozess Project3.exe (2988)					

Die Messages stehen aber beide im Filter, warum wird die Form dann trotzdem angezeigt? :autsch: :autsch: :autsch:
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 23.07.08 22:05 
Niemand eine Idee?
Irgendwas muss ja falsch sein sonst würde es ja funktionieren :gruebel: