Autor Beitrag
Smikey
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 45

Win XP, kUbuntu 6.06
Delphi 2005 Architect
BeitragVerfasst: Sa 24.02.07 15:49 
ich versuche gerade, beim programmstart fenster wieder zu erstellen, die beim letzen ausfuehren des programms gespeichert wurden (fensterpositionen, inhalt etc)...

nun uebernimmt er aber meine fensterpositionen nicht...
warum ?

ausblenden 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:
procedure Tmain.FormCreate(Sender: TObject);
var ini:TIniFile;
    i:Integer;
begin
nmb:=0;
actnmb:=0 ;
ini:=TIniFile.create(ExtractFilePath(ParamStr(0))+'notes.scrap');
actnmb:=ini.ReadInteger('General','notes',0);
try
for i:=1 to actnmb do
  begin
  nmb:=nmb+1;
  SetLength(note,nmb+1);
  SetLength(note_memo,nmb+1);
  SetLength(note_panel,nmb+1);
  note[i]:=TForm.Create(self);
  note[i].Width:=250;
  note[i].Height:=200;
  note[i].Top:=ini.ReadInteger(inttostr(i),'Top',0);
  note[i].Left:=ini.ReadInteger(inttostr(i),'Left',0);
  note[i].BorderIcons:=[];
  note[i].Show;
...
  end;
finally
ini.free;
end;
end;

_________________
Bloß weil du nicht paranoid bist, heißt das nicht, dass sie nicht hinter dir her sind.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 24.02.07 15:58 
Nagel mich nicht drauf fest, aber ich meine, dass die Fensterposition und -größe "zwischen" Form.Create und Form.Show auf die Standard-Vorgaben gesetzt wird. Demnach musst Du Deine Routine ins Form.Show setzen. Aber baue ein Prüfung ein, damit das nicht bei jedem Form.Show der Form durchgeführt wird.
Smikey Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 45

Win XP, kUbuntu 6.06
Delphi 2005 Architect
BeitragVerfasst: Sa 24.02.07 16:14 
bedeutet also, dass ich das fenster erstellen muss.. und fuer

ausblenden Delphi-Quelltext
1:
note[i].OnShow					

dann ne andere procedure festlegen muss die die position einstellt?

hrm.. ich weiss net.. ich bin der meinung ich hab das damals (als ich das programm schonmal angefangen hab zu schreiben) alles mit einem mal gemacht..

mfg smikey

_________________
Bloß weil du nicht paranoid bist, heißt das nicht, dass sie nicht hinter dir her sind.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 24.02.07 16:23 
Es gibt in der Jedi-Bibliothek eine Komponente die eigentlich genau das macht, was Du willst. Ich meine, dass diese Komponente das nicht im OnCreate macht. Die Programmierer werden sich was dabei gedacht haben. Bei den Jedis liegen die Sourcen ja bereit. Schau es Dir doch einfach mal an.
Smikey Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 45

Win XP, kUbuntu 6.06
Delphi 2005 Architect
BeitragVerfasst: Sa 24.02.07 16:31 
habs.. ich muss nur

ausblenden Delphi-Quelltext
1:
note[i].Show;					


VOR

ausblenden Delphi-Quelltext
1:
2:
  note[i].Top:=ini.ReadInteger(inttostr(i),'Top',0);
  note[i].Left:=ini.ReadInteger(inttostr(i),'Left',0);


bringen.. und schon ist alles bestens ;)

trotzdem danke

mfg smikey

_________________
Bloß weil du nicht paranoid bist, heißt das nicht, dass sie nicht hinter dir her sind.
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Sa 24.02.07 16:42 
user profile iconSmikey hat folgendes geschrieben:
bedeutet also, dass ich das fenster erstellen muss.. und fuer

ausblenden Delphi-Quelltext
1:
note[i].OnShow					

dann ne andere procedure festlegen muss die die position einstellt?

hrm.. ich weiss net.. ich bin der meinung ich hab das damals (als ich das programm schonmal angefangen hab zu schreiben) alles mit einem mal gemacht..

mfg smikey


Hallo,
die richtige Stelle ist die Prozedur (MainForm.) CreateParams. Ich benutze zwar eine eigene INI-Bibliothek, aber aus den folgenden Schnipseln sollte der Ablauf klar werden. Wichtig ist der Record TCreateParams.

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:
  { to MainForm }
  protected
    procedure CreateParams(var Params: TCreateParams); override;


procedure TBLMainForm.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
 { Debug_Box ('CreateParams',0);}
StrCopy (Params.WinClassName,RKLAppName);

IniSettings := TRKIniClass.create;
if IniSettings = nil then exit;
IniSettings.find_inifiles;
Application.HelpFile := IniSettings.Get_HelpFile_ss;

IniSettings.ReadMainPosition (false);
IniSettings.SetupMainPosition (false,Params);
end;

procedure TRKIniClass.SetupMainPosition (sizeable : boolean;var P : TCreateParams);
var x,y,w,h : integer;
begin
x := MainWindow_StartX;
y := MainWindow_StartY;
w := P.Width;
h := P.Height;
if sizeable then
  begin
  w := MainWindow_StartW;
  h := MainWindow_StartH;
  end;
CorrectWinPos (x,y,w,h);  { shift window if outside screen }
if MainWindow_SavePos then
  begin
  P.X := x;
  P.Y := y;
  if sizeable then
    begin
    P.Width := w;
    P.Height := h;
    end;
  end;
end;


Gruss Reinhard
Smikey Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 45

Win XP, kUbuntu 6.06
Delphi 2005 Architect
BeitragVerfasst: Sa 24.02.07 16:53 
danke..

ich habs erstmal so gelöst wie ich es beschrieben habe.. damit is alles erstmal wunderbar

solange man nicht in der ini-file per hand rumpfuscht (was man ja allgemein bei keinem programm sollte, wenn man keine ahnung hat), dann ist alles so wie ichs mir vorgestellt habe..

wird ein programm zum erstellen von notizen auf dem desktop...

mfg smikey

_________________
Bloß weil du nicht paranoid bist, heißt das nicht, dass sie nicht hinter dir her sind.