如何更换图片(50分)

  • 主题发起人 主题发起人 lsssxs
  • 开始时间 开始时间
L

lsssxs

Unregistered / Unconfirmed
GUEST, unregistred user!
我的form1里有一个image1,image1里载入一张图片,我希望我能利用openpicturedilog1来载入一张新的图片,
并且在程序退出以后,后载入的图片为再次启动程序的图片,也就是后载入的图片为image1的图片,谢谢高手
 
將圖片路徑保存在一個.INI文件中吧.下次再啟動時從中調出
 
用注册表也可以
 
能给我代码吗?我先谢谢了,我的意思是用户可以所以更改主界面的图片,我是菜鸟,希望得到源码
lsssxs@360cn.com
 
参考一下。
uses Inifiles;

procedure TMainForm.OpenIni;
//var s:string;
begin

ini:=Tinifile.create(AppDir+'LanExplorer.ini');
if not fileexists('LanExplorer.ini')
then
begin
ini.writeInteger('window position','top',top);
ini.writeInteger('window position','left',left);
ini.writeInteger('window position','width',width);
ini.writeInteger('window position','height',height);

ini.writeInteger('panel position','left_panel',LeftPanel.Width);
ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);

ini.writeString('Dock','RightDockPanel','alRight');
//ini.writeString('IP','IP2',Edit2.Text);
end
else
begin
top:=ini.ReadInteger('window position','top',50);
left:=ini.ReadInteger('window position','left',50);
width:=ini.ReadInteger('window position','width',500);
height:=ini.ReadInteger('window position','height',50);

if (width=screen.Width)and(height=screen.Height)then WindowState:=wsMaximized;

LeftPanel.Width:=ini.ReadInteger('panel position','left_panel',LeftPanel.Width);
RightPanel.Width:=ini.ReadInteger('panel position','right_panel',RightPanel.Width);
BottomPanel.Height:=ini.ReadInteger('panel position','bottom_panel',BottomPanel.Height);
end;
ini.Free;


end;

procedure TMainForm.SaveIni;
begin

if AppDir[1]='/' then exit; //open on the LAN
//showmessage(mydir);
ini:=Tinifile.create(AppDir+'LanExplorer.ini');

ini.writeInteger('window position','top',top);
ini.writeInteger('window position','left',left);
ini.writeInteger('window position','width',width);
ini.writeInteger('window position','height',height);

ini.writeInteger('panel position','left_panel',LeftPanel.Width);
ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);

{if RightDockPanel.HostDockSite = LeftPanel then
ini.writeString('Dock','RightDockPanel','alLeft')
else if RightDockPanel.HostDockSite = RightPanel then
ini.writeString('Dock','RightDockPanel','alRight')
else if RightDockPanel.HostDockSite = BottomPanel then
begin
if (RightDockPanel.Top<>BottomDockPanel.Top) then
ini.writeString('Dock','RightDockPanel','alBottomTop')
else ini.writeString('Dock','RightDockPanel','alBottomRight');
end;}

//ini.writeString('IP','IP2',Edit2.Text);

ini.Free;

end;
 
把图片的路径保存在INI文件就行了,下次打开程序时读取INI文件的图片路径,然后Load
一下就行了。
 
接受答案了.
 
后退
顶部