Autor Beitrag
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 27.06.06 14:36 
Hi,
ich habe eine Dynamische Form erstellt. Nun möchte ich aber gerne, wenn diese Sichtbar ist, dass sie auch in der tastkbar angezeigt wird.
Bei einer nicht Dynamischen Form geht das ja mit
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;


Aber ich benötige dies für eine Dynamische Form.

Wie schreibe ich das nun am besten um?

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 02.07.06 16:35 
Was meinst du mit "dynamische" Form?
Du kannst den WindowStyle für jede Form auch im nachhinein setzen:
ausblenden Delphi-Quelltext
1:
SetWindowLong(XForm.Handle, GWL_EXSTYLE, GetWindowLong(XForm.Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);					


Gruß, Motzi

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

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: So 02.07.06 16:46 
hi,
mit dynamischer Form meine ich eine Form, die zur Laufzeit des Programmes erstellt wird:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure tform2.newWindow(name:string);
var
new_form:tform;
begin
new_form:=tform.Create(new_form);
new_form.Name:=name;
new_form.Width:=400;
new_form.Height:=350;
new_form.BorderStyle:=bsdialog;
new_form.Caption:=name;
new_form.Show;
end;

Nun habe ich also folgendes versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure tform2.newWindow(name:string);
var
new_form:tform;
begin
new_form:=tform.Create(new_form);
new_form.Name:=name;
new_form.Width:=400;
new_form.Height:=350;
new_form.BorderStyle:=bsdialog;
new_form.Caption:=name;
new_form.Show;
SetWindowLong(new_form.Handle, GWL_EXSTYLE, GetWindowLong(new_form.Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);
end;


trotzdem wird die Form nicht unten in der taskleite angezeigt.

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 02.07.06 17:26 
Hm.. sollte so auch irgendwie gehen, aber du kannst es auch anders machen indem du eine neue Klasse von TForm ableitest, dort CreateParams überschreibst und dann einfach dynamisch Instanzen dieser Klasse erstellst.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type
  TAppForm = class(TForm)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

procedure TAppForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;

procedure tform2.newWindow(name:string);
var
  new_form: TAppForm;
begin
  new_form := TAppForm.Create(Self);
  ...
end;


Außerdem war in deinem Code ein potenzieller Fehler:
ausblenden Delphi-Quelltext
1:
new_form:=tform.Create(new_form);					

Der Parameter von Create sollte entweder nil oder eine Instanz von TComponent sein, welcher der Owner des neu erstellten Objektes ist. Du übergibst aber die noch _nicht initialisierte_ Variable "new_form"!

Gruß, Motzi

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

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: So 02.07.06 17:35 
Hi,
ok ich hab e das mal ausprobiert, aber nun bekomme ich diesen Fehler:
Benachrichtigung über Debugger-Exception hat folgendes geschrieben:
Im Projekt Project1.exe ist eine Exception der Klasse EResNotFound mit der Meldung 'Ressource TAppForm wurde nicht gefunden' aufgetreten.


Ich habe es genau so gemacht, wie du vorgeschlagen hast, ich habe sogar die Klasse immer an andere Stellen der Unit geschrieben, hat auch nichts gebracht :(

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 02.07.06 19:35 
Oh.. an das hab ich nicht gedacht, aber so sollte es gehen:

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:
type
  TAppForm = class(TForm)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure TAppForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;

constructor TAppForm.Create(AOwner: TComponent);
begin
  GlobalNameSpace.BeginWrite;
  try
    CreateNew(AOwner);
    if (ClassType <> TAppForm) and not (csDesigning in ComponentState) then
    begin
      Include(FFormState, fsCreating);
      try
        if not InitInheritedComponent(Self, TAppForm) then
          raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
      finally
        Exclude(FFormState, fsCreating);
      end;
      if OldCreateOrder then DoCreate;
    end;
  finally
    GlobalNameSpace.EndWrite;
  end;
end;

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

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: So 02.07.06 20:02 
mhh. jetzt wirft mir der Compiler das hier an den Kopf:
Der Compiler hat folgendes geschrieben:
[Fehler] Unit2.pas(103): E2003 Undefinierter Bezeichner: 'SResNotFound'

markiert wird dabei diese Zeile: raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);

Klammer ich das aber aus
ausblenden Delphi-Quelltext
1:
2:
3:
4:
      try
//        if not InitInheritedComponent(Self, TAppForm) then
//          raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
      finally

dann funktioniert es genau so wie es soll.

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 02.07.06 22:34 
SResNotFound stammt aus der Unit RTLConsts.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!