Autor Beitrag
delvieh
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 46

WinXP, Win98
D4 Standard, D7 Personal
BeitragVerfasst: Mo 09.01.06 19:13 
Hi,

ich habe drei Formulare,

frmMain (FormStyle = fsMDIForm) mit einem edtMain (TEdit).
frmA (FormStyle = fsMDIChild) mit einem edtA (TEdit).
frmB (FormStyle = fsMDIChild) mit einem edtB (TEdit).

Die beiden Childs sind auch in der Anwendung zu sehen und lassen sich anwählen...

Nun möchte ich wenn ich im frmMain.edtMain die Entertaste drücke und dort nen A drin ist den Eingabefokus zum frmA.edtA übergeben.

Ich pack es einfach nicht... was mache ich falsch?

ausblenden Delphi-Quelltext
1:
2:
  if (Key=#13) then frmMain.ActiveControl:=frmA.edtA;
  if (Key=#27) then frmMain.ActiveControl:=frmB.edtB;



Ich bekomme immer die Fehlermeldung

"Ein deaktiviertes oder unsichtbares Fenster kann den Fokus nicht erhalten."

:( Ja wie? Das frmMain ist doch zu sehen, ähm *sprachlos*

Hoffe es gibt ne Lösung... Gruß Frank
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 11.01.06 06:08 
Wenn Du Dir in der Hilfe anschaust, für was die Eigenschaft ActiveControl ist, dann würdest Du verstehen, warum das so nicht geht.
Zitat:
Beschreibung

Mit ActiveControl können Sie ermitteln oder festlegen, welches Steuerelement im Formular den Fokus hat. In einer Anwendung kann immer nur ein Steuerelement aktiv sein.

Hat das Formular momentan nicht den Fokus, gibt ActiveControl das Steuerelement an, das beim Aktivieren des Formulars den Fokus erhält.


Du musst einfach das anderes Formular anzeigen (frmA.Show), dort bestimmst Du per ActiveControl bzw. über die TabOrder-Eigenschaft jeder Komponente, welche den Fokus hat.
delvieh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 46

WinXP, Win98
D4 Standard, D7 Personal
BeitragVerfasst: Mi 11.01.06 14:16 
Einfach nur Anzeigen klappt auch nicht...

frmA.Show;

Wird zwar ausgeführt aber der Focus wird nicht auf das frmA gelegt sondern bleibt auf frmMain, weil frmA ja sichtbar als MDI Child ist :(


Gruß Frank
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 11.01.06 21:40 
OK, dann versuch noch ein formA.BringToFront und wenns nicht ausreicht ein formA.SetFocus
Kannst grad schlecht probieren ;-)