Registriert seit: 15. Sep 2006
165 Beiträge
|
Re: Positionen aller Forms wiederherstellen
13. Jan 2010, 03:07
Delphi-Quellcode:
Function GetPlacement(AForm:TForm):TRect;
Var WP : TWindowPlacement;
begin
GetWindowPlacement(AForm.Handle, @WP);
with WP.rcNormalPosition do
begin
Result.Top:=Top;
Result.Left:=Left+Screen.WorkAreaLeft; //Taskleiste links/rechts oder unten?
Result.Right:=Right+Screen.WorkAreaLeft;
Result.Bottom:=Bottom;
end;
end;
Function Save_Ini_Others(Form_:TForm;Filename_:String;Typ_:integer):Boolean;
var
Ini: TIniFile;
Section:String;
FN_:String;
FP_:String;
R_:TRect;
begin
Result:=False;
FN_:=Filename_;
while trim(FN_)='' do
exit;
FP_:=Extractfilepath(FN_);
while trim(FP_)='' do
exit;
if not DirectoryExists(FP_) then
ForceDirectories(FP_);
Deletefile(PCHar(FN_));
Ini:=TIniFile.Create(FN_);
try
with ini do
begin
Section:=Form_.Name;
WriteInteger(Section,'WindowState',Integer(Form_.WindowState));
case typ_ of
0:R_:=GetPlacement(Form_); //Sizeable/Minimier-/Maximierbar
1:R_:=Form_.BoundsRect; //Fix
end;
WriteInteger(Section,'Left',Integer(R_.Left));
WriteInteger(Section,'Top',Integer(R_.Top));
WriteInteger(Section,'Width',Integer(R_.Right-R_.Left));
WriteInteger(Section,'Height',Integer(R_.Bottom-R_.Top));
end;
Result:=True;
finally
Ini.Free;
end;
end;
Delphi-Quellcode:
Function Load_Ini_Others(Form_:TForm;Filename_:String;Typ:Integer):Boolean;
var
Ini: TIniFile;
Section:String;
IntData:integer;
FN_:String;
begin
Result:=False;
FN_:=Filename_;
while not Fileexists(FN_) do
exit;
Ini:=TIniFile.Create(FN_);
try
with Ini do
begin
Section:=Form_.Name;
IntData:=ReadInteger(Section,'WindowState',-1);
//...Windowstate... bei mir aber standard verkleinert
IntData:=ReadInteger(Section,'Left',screen.WorkAreaLeft);
Form_.Left:=IntData;
IntData:=ReadInteger(Section,'Top',screen.DesktopTop);
Form_.Top:=IntData;
case Typ of
1:; //Fix
else begin
IntData:=ReadInteger(Section,'Width',400);
Form_.Width:=IntData;
IntData:=ReadInteger(Section,'Height',300);
Form_.Height:=IntData;
end;
end;
end;
end;
result:=True;
finally ini.Free;end;
end;
für jede Form eine Ini Datei mit entsprechendem Namen
Die Unter-/Überschreitung der Grenzen musst du noch einbauen
lg busy
I love DiscCat
|
|
Zitat
|