Autor Beitrag
Josef-B
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Sa 17.09.11 12:26 
Hallo,

ich möchte in meiner Form ein neues Form erzeugen.

ausblenden Delphi-Quelltext
1:
2:
form2 := tform2.create(self);
form2.show;


Form2 soll aber nicht den Focus bekommen, sondern
der Focus soll bei Form1 bleiben.
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: Sa 17.09.11 12:55 
Hol dir den Focus doch einfach sofort wieder zurück:
ausblenden Delphi-Quelltext
1:
2:
3:
form2 := tform2.create(self);
form2.show;
self.setfocus;
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Sa 17.09.11 13:06 
Ja, aber dann wird wieder onActivate beim Form1 aufgerufen.

Das möchte ich eben nicht.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19338
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 17.09.11 14:42 
Bei OnActivate vermute ich, dass dahinter ein Event hängt, in den du Code geschmissen hast, der dann nach der Anzeige des Formulars ausgeführt werden soll. Meistens finde ich da allerdings Code, der da gar nicht hingehört. Und dein Fall liest sich exakt wie ein solcher Konstruktionsfehler...

Was machst du denn dort?
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: Sa 17.09.11 15:22 
user profile iconJosef-B hat folgendes geschrieben Zum zitierten Posting springen:
Ja, aber dann wird wieder onActivate beim Form1 aufgerufen.
Das möchte ich eben nicht.

OnActivate wird auch immer aufgerufen wenn der Anwender zwischen Form2 und Form1 wechselt.
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Sa 17.09.11 20:57 
Das Form2 zeigt nur eine Message in einem Tedit an.

Es ist ne Statusmeldung. Das Fenster soll genauso lange sichtbar sein, bis
in diesem Falle eine umfangreiche Datenbankabfrage ausgeführt habe.

Nur, dass der Nutzer weiss, dass es gleich weitergeht und nicht nervös wird.

Würde auch mit einer Messagebox gehen, da weiss ich nicht wie ich die
auf Befehl bzw. beim After Open meiner Query schliesse, ohne dass der
Nutzer nochmal klicken muss.

Das ist der Hintergrund, warum eben diese "MessageForm" nicht den Focus
erhalten soll.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19338
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 18.09.11 03:17 
Es sollte gehen, indem du statt Show einfach ShowWindow benutzt:
ausblenden Delphi-Quelltext
1:
ShowWindow(Form2.Handle, SW_SHOWNOACTIVATE);					
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: So 18.09.11 12:02 
mit showwindow bekommt das Formular jetzt zwar nicht den Focus.

Aber mein TEdit auf dem Form2 wird nicht mit angezeigt.

bei Form2.show wird es mit angezeigt.

Und das Form2 steht immer bei Top 1 und Left 1. Also oben links in der Ecke,
egal was ich bei Form2.Position einstelle
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19338
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 18.09.11 14:16 
Das hatte ich nicht ausprobiert. Dann musst du danach noch Visible auf True setzen. Siehe Anhang.
Einloggen, um Attachments anzusehen!
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: So 18.09.11 15:32 
Ja das geht jetzt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Form2 := TFForm2.create(self);
ShowWindow(Form2.Handle,SW_SHOWNoActivate);
Form2.Visible := true;
Form2.edit1.text := 'Daten werden geladen';
application.processmessages;


Ich hatte das edit1.text := 'blabla' zuerst im oncreate von Form2,
da hat er das Tedit nicht angezeigt.

Vielen Dank.