Autor Beitrag
mick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Fr 10.12.04 16:33 
hi zusammen.

habe ein programm geschrieben, bei dem im ablauf einiges intern berechnet wird und auch einiges grafisch auf dem bildschirm ablaeuft. im mainmenue habe ich nun einen eintrag erstellt "neu"; dafuer, dass alle einstellungen, bilder, komponenten etc. wieder in den ursprungszustand versetzt werden. so, als wuerde ich die anwendung komplett neu aufrufen. wie mache ich das nun im code? soll ich da dann alles nach mausklick auf "neu" manuell zurueckstellen? oder gibt es in delphi eine funktion, die mir einen "reset" zum startzustand meiner anwendung herstellt?

danke im voraus,
ciao,
mijozi.
Pr0g
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: Fr 10.12.04 16:36 
Hallo,

das wirst du wohl selber programmieren müssen, also alle Einstellungen zurücksetzten.

MfG Pr0g
mick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Fr 10.12.04 16:55 
aergerlich, denn ich habe ienige imagekomponetnen waehrend des programmablaufs "geloescht" (free). die muessten dann ja wieder erzeugt werden.
gibt es keine moeglichkeit von delphi sich den startzustand eines programms zu merken?

ciao,
mijozi.
Pr0g
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: Fr 10.12.04 16:57 
Ich kann es nicht genau sagen, bezweifele es aber stark. Du könntest auch alle Objekte freigeben und dann neu Createn, dadurch hast du sie ja dann zurückgesetzt.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Fr 10.12.04 17:01 
wegen den image komponenten:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if MeinImage = nil then MeinImage := TImage.Create;

// oder

if not Assigned(MeinImage) then MeinImage := TImage.Create;



was du im Constructor eventuell noch übergeben musst, musst du halt nachschaun. du kannst natürlich auch deine Default-Daten irgendwo in einem array abspeichern (also nen array mit angehängter recordstruktur), dann musst nur ne schleife durchgehen et voilâ du hast deine bilder wieder in der ausgangs-einstellung


gruß
rochus

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
mick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Di 28.12.04 16:19 
hallo rochus.

deine idee klingt gut, leider kann ich das nicht alleine umsetzen. kannst du mir da helfen?
ausblenden Delphi-Quelltext
1:
if not Assigned(MeinImage) then MeinImage := TImage.Create;					


was muss ich da noch uebergeben bei create? kenne mich damit nicht genug aus...

und zu array-struktur mir records: wie muesste ich mir das vorstellen? koenntest du da auch etwas zu erklaeren?

danke + ciao,
mijozi.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 28.12.04 16:23 
Sagt mal, wär's nich einfacher, einfach das Programm eu zu starten... ShellExecute und so... :wink:

Oder ist das wieder "schlechter Programmierstil"??? :D

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 28.12.04 16:25 
du musst gar nichts übergeben ^^
die erste zeile (mit nil) funktioniert so garantiert, habe das auch so verwendet.
natürlich muss meinImage vom typ timage sein
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 28.12.04 16:51 
die anwendung mit shellexecute neu zu starten halte ich für übertrieben.
lieber die anwedung mit einem loopenden batchfile starten

ausblenden Quelltext
1:
2:
3:
4:
@echo off
:10
slsk.exe
goto 10


die anwendung sollte sich natürlich immer selber schliessen, wenn alles erledigt ist...
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 28.12.04 16:56 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
  TImageSettings = record
    ImageName : string;
    PosX      : integer;
    PosY      : integer;
    Width     : integer;
    Height    : Integer;
  end;
  

  TMyForm = class(TForm)
    Private
      FImageSettings : array of TImageSettings;
      procedure AddImageSettings(strImageName: string; X,Y,Width,Height: Integer);
      procedure LoadImageDefaults;
    public
      
  end;


procedure formcreate;
begin
  SetLength(FImageSettings,0);
  { für jedes Bild }
  AddImageSettings('BildName1',20,20,200,200);
  AddImageSettings('BildName2',75,23,123,623);
  { und so weiter ...}
end;


procedure AddImageSettings(strImageName: string; X,Y,Width,Height: Integer);
var
  intTemp: integer;
begin
  intTemp := Length(FImageSettings);
  SetLength(FImageSettings,intTemp+1);
  FImageSettings[intTemp].ImageName := strImageName;
  FImageSettings[intTemp].PosX := X;
  FImageSettings[intTemp].PosY := Y;
  FImageSettings[intTemp].Width := Width;
  FImageSettings[intTemp].Height := Height;
end;


procedure LoadImageDefaults;
var
  i: Integer;
begin
  for i:=0 to Length(FImageSettings)-1 do begin
    if FindComponent(FImageSettings[i].ImageName)<>nil then begin
      with FindComponent(FImageSettings[i].ImageName) do begin
        { Daten zuweisen }
      end;
    end;
  end;
end;

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 28.12.04 16:56 
@retnyg
Häh??? Wo isn da der Unterschied??? In ner Batchdatei immer neu starten oder Programm beenden und gleichzeitig neu starten... :D

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 28.12.04 17:03 
bleibt mal on topic... :roll:

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 28.12.04 17:36 
Wat denn?? Simma doch... Wenn er sein Proggy neu startet gibbet keine Probs mit .Create un so... Is doch viel einfacher...

Un retnyg hat die selbe Idee gehabt und hat einen anderen Lösungsweg vorgeschlagen und ich hab gefragt, ob das nich das selbe sei... (MANN KLINGT DAS *mist*E!!!)

tja..

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 28.12.04 23:40 
Aber gerade das möchte er ja nicht, also neu starten...

Schonmal dran gedacht, dass es in vielen Programmen den Menüeintrag "Datei->Neu" gibt? Vielleicht hat er ja vor, das darin einzubaun.

Ne weitere Möglichkeit wäre, die Darstellung in ein MDI Fenster zu legen und immer das zu zerstören/erstellen. Dann könnte man nämlich auch vorherige "Ergebnisse" sehen (je nachdem, was die Software können soll!)

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
mick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Mi 29.12.04 12:52 
hi leute -

schoen, dass hier sich so rege etwas tut.

ja, es geht um ein schachprogramm und ich moechte mit datei-neu einfach eine neue partie starten. dazu muessen die images auf dem grafischen spielbrett "zurueckgesetzt" werden. da sie teils in der partie zuvor geloescht worden (free), muessen die nun wieder her. auch stellt sich das prob, wenn ich eine zuvor gespeicherte partie laden/oeffnen will.

habe es jetzt so geloest, dass ich das grafische brett mit 64 kl. images versehe und die bilder der images immer neu lade nach jedem zug. loesche die images als nicht mehr mit free, sondern lade bei leerem spielfeld einfach ein komplett transparentes image rein. das neue problem: flimmern. siehe dazu mein thema unter
www.delphi-forum.de/...34200&highlight=.

ciao,
mijozi.