Autor Beitrag
Scofield2011
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Sa 20.10.12 00:18 
Hallo,

ich habe zwei sich in Teilen überlappende Forms. Leider ist dabei immer das SubForm, also jenes welches erst von meinem MainForm aus generiert wird, im Vordergrund. Gibt es eine Möglichkeit, dass immer das Form im Vordergrund, das den Focus hat, also aktiviert ist?

Vielen Dank schon einmal im Voraus

Scofield2011
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4807
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 20.10.12 09:30 
Wie rufst du denn die Subform auf?
Wahrscheinlich hat diese als Owner die MainForm.
Scofield2011 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Sa 20.10.12 12:06 
user profile iconTh69 hat folgendes geschrieben Zum zitierten Posting springen:
Wie rufst du denn die Subform auf?
Wahrscheinlich hat diese als Owner die MainForm.


Ja hat sie.

Ich rufe es im MainForm mit folgenden Code Zeilen auf:

ausblenden C#-Quelltext
1:
2:
SubForm.Owner = this;
SubForm.Show();


Ich habe schon mit der TopMost Option experimentiert, wenn ich bei dem MainForm von Anfang die Option auf true setze, ist es natürlich immer on top, aber leider bleibt es das dann auch. Wenn ich aber beispielsweise einen Button verwendet, der diese Option setzt, funktioniert der Wechsel nicht mehr.
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4807
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 20.10.12 13:13 
Hallo,

genau das meinte ich. ;-)
Laß mal die Owner-Zuweisung weg (bzw. setze sie explizit auf null), und überprüfe dann mal das Verhalten der beiden Forms.
Scofield2011 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Do 25.10.12 20:14 
Korrigiere mich bitte, wenn ich mich irre, aber ohne die Owner-Zuweisung kann ich doch keine Methoden des jeweils anderen Form aufrufen, oder?
Oliver M.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 109
Erhaltene Danke: 1

Win 8 CP
VS 11 Beta
BeitragVerfasst: Do 25.10.12 23:47 
Methoden müsstest du so oder so aufrufen können. Form.Owner gibt nur an, welche Form immer im Vordergrund sein soll.