请问高手:在程序中怎么限制一个窗口只能被打开一次?

sharesoft21 2003-10-15 09:13:06
在程序中怎么限制一个窗口只能被打开一次?
...全文
162 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdbnzc 2003-10-16
  • 打赏
  • 举报
回复
做个标签就行了,
bool flag = false
打开以后flag = true
判断一下就可以了
binbin2000 2003-10-16
  • 打赏
  • 举报
回复
private Form myForm;
prviate void ShowForm
{
if( this.myForm == null)
{
this.myForm = new Form();
}
this.myForm.Show();
}
fgc5201314 2003-10-15
  • 打赏
  • 举报
回复
foreach(Form f in this.MdiChildren)
{
if (f is frmhouseinfo)
{
f.Activate();////Activate the form
f.WindowState=0;
return;
}
}
frmhouseinfo frmhinfo=new frmhouseinfo();
frmhinfo.MdiParent=this;
frmhinfo.Show();
saucer 2003-10-15
  • 打赏
  • 举报
回复
use a singleton pattern,

class YourForm : Form
{
private static YourForm syf;
public static YourForm CreateForm()
{
if (syf == null)
{
syf = new YourForm();
}
return syf;
}
private YourForm()
{
//....
}
}

then do

YourForm yf = YourForm.CreateForm();
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
http://xml.sz.luohuedu.net/xml/ShowList.asp?id=12
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
public static Process RunningInstance()
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName (current.ProcessName);
//Loop through the running processes in with the same name

foreach (Process process in processes)
{
//Ignore the current process
if (process.Id != current.Id)
{
//Make sure that the process is running from the exe file.
if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
{
//Return the other process instance.
return process;
}
}
}
//No other instance was found, return null.
return null;
}
大户翁 2003-10-15
  • 打赏
  • 举报
回复
在窗口打开时 判断是否为 null

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧