using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace MenuHistory
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string address = System.Environment.CurrentDirectory;
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void 打開ToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = "";
this.openFileDialog1.ShowDialog();
StreamWriter s = new StreamWriter("Menu.ini", true);
s.WriteLine(openFileDialog1.FileName);
s.Flush();
s.Close();
ShowWindows(openFileDialog1.FileName);
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
ToolStripMenuItem menu = (ToolStripMenuItem)sender;
ShowWindows(menu.Text);
}
public void ShowWindows(string fileName)
{
Image p = Image.FromFile(fileName);
Form f = new Form();
f.MdiParent = this;
f.BackgroundImage = p;
f.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists("Menu.ini"))
{
StreamReader sr = new StreamReader("Menu.ini");
int i = this.文件ToolStripMenuItem.DropDownItems.Count;
while (sr.Peek() >= 0)
{
ToolStripMenuItem menuitem = new ToolStripMenuItem();
this.文件ToolStripMenuItem.DropDownItems.Insert(i, menuitem);
i++;
menuitem.Click += new EventHandler(menuitem_Click);
}
sr.Close();
}
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 關閉所有ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form frm in this.MdiChildren)
{
frm.Close(); //關閉子窗體
}
}
}
}
你說的那個東西代碼裡沒有