Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 14.10.09 20:01 
Hi, Delpher,

wie kann ich in zwei Formularen, die gleichzeitig sichtbar sind, abwechselnd arbeiten, so dass aber beide noch sichtbar sind, aber halt nur eines aktiv?
(Das zweite schließe ich dann "normal" mit dem x-Icon rechts oben.)

Ich habe es versucht mit Form2.Show und mit Form2.ShowModal aber (noch) ohne Erfolg.

Danke, Detlef


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mi 14.10.2009 um 23:46

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 14.10.09 20:45 
Eigentlich sollte es mit Form2.Show gehen - was gefällt dir denn an dem Ergebnis nicht?

_________________
PROGRAMMER: A device for converting coffee into software.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 08:03 
Hi, Xentar,

mir gefällt nicht, dass das zweite Formular verschwindet, wenn ich das erste anklicke.
Es soll so lange sichtbar bleiben, bis ich es "aus-x-e".
Geht das?
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Do 15.10.09 08:08 
Moin ..., meinst du damit das alle Formulare weg sind wenn du das erste geschlossen hast?
Wenn ja, das ist normal da dies das Hauptformular ist. Es gäbe dann aber die Möglichkeit ein 'unsichtbares' Hauptformular zu erzeugen und anschliessend die Unterformulare, die du dann natürlich auch alle selbst unabhängig steuern kannst.
[Edit]Bsp. angehängt mit 2 Formularen
Einloggen, um Attachments anzusehen!
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 09:11 
Dank' dir für deine Antwort - aber ich habe auf form1 Objekte, z.B. ein DBGrid, auf das ich mich in Form2 beziehe, in der Art: if form1.dbgrid4.datasource = ...
also muss ich in form2 die Zeile uses form1 eintragen.

Und dann klappt es nicht mehr wie in deinem Beispiel <--- dieses Verhalten wäre perfekt!

Gruß, Detlef aus Lübeck

_________________
ut vires desint, tamen est laudanda voluntas
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Do 15.10.09 09:40 
... Also deine Fehlerbeschreibung ist so wie 'ich hab nen Kaugummi und der macht keine Blasen' :gruebel:
Was genau machst du denn in Form2? Vielleicht zwingen deine Änderung in Form2 das DBGrid zum refresh, womit Form1 möglicherweise den Focus erhält. Vielleicht hilft 'BeginUpdate' oder das DBGrid zu disablen, zumindest solange Form2 geöffnet ist.
Wie sieht der Fehler aus wenn du Form2 modal öffnest?
... Fragen über Fragen ...
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 09:47 
Viel einfacher:

Wenn die Formulare nebeneinander liegen - wie bei dir - dann geht der Wechsel problemlos.
Aber wenn Form2 "auf" Form1 liegt, dann überdeckt Form1 das Form2, also wie bei der Eigenschaft bringtofront, bzw sendtoback.

Vielleicht hilft es also, wenn ich die Formulare nicht-überlappend anordne?
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.10.09 09:52 
da könnte man ja recht simpel die Position des jeweilgen Formulars entsprechend setzen. Siehe dazu Form.Top, Form.Left
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 15.10.09 11:05 
Man könnte auch eines der beiden Fenster wie ein Toolfenster immer im Vordergrund des zweiten Fensters schweben lassen, wenn es das ist was du meinst?
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 14:22 
Hi, Sebastian,

Das zweite Formular soll nicht immer sichtbar sein, denn es dient nur dazu, neue Datensätze eingeben zu können.

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Do 15.10.09 15:07 
Versuch es doch mal mit Hide und Show :P

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 15.10.09 15:08 
user profile iconD. Annies hat folgendes geschrieben Zum zitierten Posting springen:
Das zweite Formular soll nicht immer sichtbar sein, denn es dient nur dazu, neue Datensätze eingeben zu können.
Dann sollte ShowModal doch genau das richtige sein. :gruebel:
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 18:42 
Du hast natürlich recht.
Mein Wunsch war es halt nur, zwischen den Forms hin- und herschalten zu können - und das das Form2 erst beim aus-x-en verschwindet.

Geht also wohl nicht (?)

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 15.10.09 18:50 
Das zweite Formular soll also nicht immer im Vordergrund des zweiten zu sehen sein. Es soll aber auch nicht verschwinden bevor man es geschlossen hat, auch wenn man das andere anklickt.
Was denn jetzt? :eyecrazy: :?!?:
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.10.09 19:25 
hüstel. Ich rat mal in den Raum:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure myShowForm(Form, Neighbour : TForm); //zeigt Form neben Neighbor an.
begin
  Form.Left := Neighbour.Width + Neighbour.Left;
  Form.Top  := Neighbour.Top;
  Form.Show;
end;

Jetzt kann man alles was gewünscht ist :mrgreen:
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 15.10.09 19:51 
Ich checks nicht..

ShowModal: Zeigt Form2 an, sorgt dafür, dass man mit Form1 nix mehr machen kann -> möchtest du nicht

Show: Zeigt Form2 an, man kann aber gleichzeitig noch auf Form1 rumklicken -> Ist doch genau was du suchst..? Was meinst du denn mit aus-x-en? Selbst wenn ich auf Form1 klicke, und dort weiter arbeite, bleibt Form2 geöffnet, und sogar im Vordergrund von beiden - aber das kriegt man mit BringToFront und ähnlichem sicher auch noch irgendwie hin. Da wird nix automatisch geschlossen, man MUSS Form2 händisch "aus-x-en", zu Deutsch: Schließen.

_________________
PROGRAMMER: A device for converting coffee into software.
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.10.09 20:07 
naja, wenn das Mainform geschlossen wird, schließt auch die application. Man müsste im OnCloseQuery entsprechend mit Hide "escapen".
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Do 15.10.09 20:12 
Mit aus-x-en meint er sicherlich die Form mit dem X Button schliessen.

Aber fassen wir mal zusammen:
- benötigt werden 2 Formulare
- beide sollen gleichzeitig sichtbar sein, eines aber nur den Focus haben (aktiv sein)
- wenn Form2 durch Form1 überdeckt ist soll Form1 nach vorne geholt werden
- Form 2 wird aber nur zur Dateneingabe benötigt

Ich komme da auch net mehr mit, Sorry

@Annies: Was ich nur net verstehe, warum erzeugst du Form2 dann nicht modal. Wenn es nur zur Datenänderung benutzt wird, erfüllt es doch sonst keinerlei Funktion und kann doch nach der gemachten Änderung geschlossen werden.
Vielleicht wäre es ratsam einfach mal ein einfaches Bsp. zu erstellen damit wir wissen was genau gemeint ist!

[Edit] @FinnO: Es gibt doch genug Möglichkeiten das beenden der Application zu unterbinden.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 15.10.09 20:36 
Hi, Xentar,

Form1 ist wsmaximized und Form2 ist z.B. setbounds(0, 300, 300, 200);
Also: Show ist richtig.

Aber: Wenn Form2 sichtbar ist muss ich noch auf Form1 rumklicken können - und form2 soll sichtbar bleiben, so dass ich wieder auf form2 wechseln kann - genau DAS geht bei mir nicht.

Gruß, Detlef (wir schaffen das!)

_________________
ut vires desint, tamen est laudanda voluntas
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.10.09 20:46 
achsooooo :) Da hilft die Einblendung als Tool. Müsste mit Borderstyle bsToolWindow gehen.