Ich benutze den folgenden Code zum Erstellen einer neuen Form. Dies soll bei jedem Klick auf den Button geschehen und jede neue Form soll etwas nach Rechts-unten verschoben werden.
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| if New = 1 then begin FNew[Count] := TFNew.Create(FMain); FNew[Count].Show; FNew[Count].Caption := 'FNew[' + IntToStr(count) + ']'; posx := FNew[Count].Left; posy := FNew[Count].Top; Inc(count); Inc(New); end else begin FNew[Count] := TFNew.Create(FMain); FNew[Count].Caption := 'FNew[' + IntToStr(count) + ']'; posx := posx + 20; posy := posy + 30; SetWindowPos(FNew[count].Handle, HWND_TOP, posx, posy, FNew[count].Width, FNew[count].Height, SWP_SHOWWINDOW); ShowWindow(FNew[count].Handle, SW_SHOWNORMAL); Inc(count); Inc(New); end; |
Zur Erklärung
count ist vom Typ
Byte,
New ist vom Typ
Byte,
FNew ist ein
array [0..255] von
TFNew und
posx,
posy werden zum Verschieben benötigt.
New wird bei
Form1.FormCreate auf 1 und
count auf 0 gesetzt.
Jetzt das Problem:
Wenn ich auf den Button klicke wird die erste Form angezeigt. auch die Caption stimmt. Wenn ich jetzt noch mehrmals draufklicke erscheinen zwar neue Formen, die auch richtig durchgezählt sind, aber das Memo, das drauf sein sollte ist nicht mehr da und ich kann die neu erstellten Fenster nur noch über
Strg+F2 loswerden.
Weis jemand, wo der Fehler ist?
There are only 10 types of people: those who understand binary and those who don't.