Autor Beitrag
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 21.05.07 20:29 
Hallo Leute,

Ich will ein Formular anzeigen mit Form2.Show. Allerdings soll das "aufrufende" Fenster Form1 den Fokus nicht verlieren! Form2 ist StayOnTop.

Gibt es da eine Möglichkeit, außer dieser:
ausblenden Delphi-Quelltext
1:
2:
Form2.Show;
Form1.SetFocus;


Danke schon mal!
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mi 23.05.07 20:04 
Hat keiner eine Idee?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 23.05.07 21:36 
Hallo,

die Form2 schon in der Projekt-Datei *.dpr aufrufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Form2.Show;                              //<-----------------
  Application.Run;
end.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Do 24.05.07 12:19 
mh, das geht leider nicht, weil das ganze zB. OnClick passieren muss...
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 24.05.07 12:28 
Was ist denn an der Lösung, die du im ersten Beitrag gepostet hast, auszusetzen?

_________________
We are, we were and will not be.
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Fr 25.05.07 12:10 
das Problem ist, an der ersten Lösung, dass ein Thread, der nichts mit Form1 zu tun hat Form2 "ohne Fokus" anzeigen soll... und der Thread sollte unabhängig von Form1 bleiben! Aber ist jetzt doch nicht soo wichtig.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 25.05.07 12:39 
Dann würde ich das so machen, dass der Thread ggf zwei weitere Parameter bekommt. Einmal die ShowForm, die angezeigt werden soll, und dann die FocusForm, die den Fokus beim Show der anderen bekommt. Nachdem der Thread erzeugt wurde, müssten dann diese beiden Parameter entsprechend gesetzt werden.
Evtl. wäre es auch besser, nicht die Form1 direkt zu übergeben, sondern nur deren Handle, um dann vom Thread aus eine Fokus-Message dahin zu senden. Irgendwie in der Art eben.

_________________
We are, we were and will not be.
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Fr 25.05.07 16:11 
ah, das lässt sich machen. Vom Prinzip her gut! Das mach ich jetzt auch...
Schade nur: wenn ich Form1 modal anzeige, dann verschwindet natürlich Form2 dahinter. Naja, jedenfalls ist mir das eine Hilfe bei nicht-modalen Fenstern! Danke.