ntractedSubBlock.gif"> ...{
if (File.Exists(FILE_NAME))
...{
StringBuilder strCaption = new StringBuilder(256);
GetPrivateProfileString("Form", "Caption","Default Caption",
strCaption,
strCaption.Capacity,
FILE_NAME);
this.Text= strCaption.ToString();
int myWidth= GetPrivateProfileInt("Form", "Width", this.Width,FILE_NAME);
this.Width=myWidth;
int myHeight= GetPrivateProfileInt("Form","Height", this.Height,FILE_NAME);
this.Height= myHeight;
int myLeft= GetPrivateProfileInt("Form","Left", this.Left,FILE_NAME);
this.Left=myLeft;
int myTop = GetPrivateProfileInt("Form","Top", this.Top, FILE_NAME);
this.Top=myTop;
}
}
//当按钮被点击, 保存窗体的位置和大小信息到test.ini 文件中,响应代码如下:
private void button1_Click(object sender, System.EventArgs e)
...{
string strCaption = this.Text;
WritePrivateProfileString("Form", "Caption", strCaption, FILE_NAME);
WritePrivateProfileString("Form", "Width", this.Width.ToString(), FILE_NAME);
WritePrivateProfileString("Form", "Hight", this.Height.ToString(), FILE_NAME);
WritePrivateProfileString("Form", "Left", this.Left.ToString(), FILE_NAME);
WritePrivateProfileString("Form", "Top", this.Top.ToString(), FILE_NAME);
}
//当程序结束时,保存窗体的位置和大小信息到test.ini 文件中,响应代码如下:
private void Form1_Closing( object sender, System.ComponentModel.CancelEventArgs e)
...{
string strCaption = this.Text;
WritePrivateProfileString("Form", "Caption"