窗体隐藏到托盘后,不执行按钮操作,急求解决方案!
窗体隐藏到托盘后,不执行,急求解决方案!已添加 notifyIcon,隐藏到托盘代码:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//注意判断关闭事件Reason来源于窗体按钮,否则用菜单退出时无法退出!
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true; //取消"关闭窗口"事件
this.WindowState = FormWindowState.Minimized; //使关闭时窗口向右下角缩小的效果
this.Hide();
return;
}
}
this.btn_login.PerformClick();//自动登录
这一句执行了,
但是没有进入btn_login_fun()函数里面。。。。
求解。。。
--------------------编程问答-------------------- 想到一个笨方法。。。
在执行this.btn_login.PerformClick();//自动登录
之前,添加 this.show()
貌似已经通过调试。。
但总不知道原因是啥。。。请知情人告之。。。。 --------------------编程问答-------------------- 把btn事件中的方法提取出来,把this.btn_login.PerformClick()执行的方法替换成,之前提取的方法 --------------------编程问答-------------------- 擦,你这样对话框应该还是关闭了吧,需要在DefWndProc方法
--------------------编程问答-------------------- 楼主的this.btn_login.PerformClick();//自动登录
protected override void DefWndProc(ref Message m)
{
switch(m.Msg)
{
case CommPara.WM_SYSCOMMAND:
{
if ((int)m.WParam == CommPara.SC_CLOSE)
{
//....
return;
}
}
break;
}
base.DefWndProc(ref m);
}
和btn_login_fun()怎么不贴出来,看不懂 --------------------编程问答--------------------
。。。没看懂。。 --------------------编程问答-------------------- 代码不全,鉴定完毕.
补充:.NET技术 , C#