1.一个应用程序只能被用户打开一次
process mobj_pro =process.getcurrentprocess();
process[] mobj_prolist=process.getprocessesbyname(mobj_pro.processname);
if(mobj_prolist.length>1)
{
messagebox.show("当前的应用程序已打开!", "系统提示", messageboxbuttons.ok, messageboxicon.exclamation, messageboxdefaultbutton.button1);
return;
}
2.一个框架窗口下只打开一个子窗口
customeradd pobj_customeradd;
form pobj_customeradd_return=checkisexit("customeradd");
if(pobj_customeradd_return==null)
{
pobj_customeradd=new customeradd();
opensheet(pobj_customeradd);
}
else
{
opensheet((customeradd)pobj_customeradd_return);
}
void opensheet(form pobj_form)
{
pobj_form.mdiparent=this;
pobj_form.show();
}
/**//// <summary>
/// 判断窗口是否存在
/// </summary>
/// <param name="ps_windowname">窗口的名称</param>
/// <returns>存在返回此窗口的实例 不存在返回null</returns>
form checkisexit(string ps_windowname)
{
for(int i=0;i<this.mdichildren.length;i++)
{
if(this.mdichildren[i].name==ps_windowname)
{
return this.mdichildren[i];
}
}
return null;
}
3.弹出式窗口显示渐变效果
在页面上添加一个timer控件fadetimer,interval设为50
类的实例变量为
private m_showing=true;
在form_load中写:
opacity = 0.0;
activate();
refresh();
fadetimer.start();
refresh(); 在timer控件的tick事件中写:
if (m_showing)
{
double d = 1000.0 / fadetimer.interval / 100.0;
if (opacity + d >= 1.0)
{
opacity = 1.0;
fadetimer.stop();
}
else
{
opacity += d;
}
}
else
{
double d = 1000.0 / fadetimer.interval / 100.0;
if (opacity - d <= 0.0)
{
opacity = 0.0;
fadetimer.stop();
}
else
{
opacity -= d;
}
}
4.在控件textbox中实现按回车键相当于tab键的作用
public class ostextbox:textbox
{
public ostextbox()
{
}
bool mb_iskeyenter=true;
[
category("data"),
defaultvalue(true),
mergableproperty(false)
]
public bool iskeyenter
{
get
{
return mb_iskeyenter;
}
set
{
mb_iskeyenter=value;
}
}
protected override void onkeypress(keypresseventargs e)
{
base.onkeypress (e);
if(mb_iskeyenter)
{
if (e.keychar == (char)keys.enter)
{
sendkeys.send("{tab}");
}
}
}
}
新闻热点
疑难解答