在C#中如何实现点击最小化后把程序最小化只剩标题栏
就和QQ登录窗体点击最小化后的情况一样,急用!!!!!注意是和QQ的登录窗口最小化之后的情形相似,而不是登陆后的窗体!!!!!!...
就和QQ登录窗体点击最小化后的情况一样,急用!!!!!
注意是和QQ的登录窗口最小化之后的情形相似,而不是登陆后的窗体!!!!!! 展开
注意是和QQ的登录窗口最小化之后的情形相似,而不是登陆后的窗体!!!!!! 展开
5个回答
展开全部
右下方托盘?
加一个NotifyIcon控件
设置Icon选项,选择一个Icon图标。(QQ目录下搜索一下.ICO,找个企鹅弄上去)
这样你的程序运行的时候右下方就有图标了
控制notifyIcon1的Visible属性让它在右下方隐藏/显示
——————————————————————
楼主可曾测试过代码?我说的就是那效果。
要隐藏窗体
this.Visible=false;不就隐藏掉了?
最小化事件:
this.Visible=false;
notifyIcon1.Visible=true;
恢复事件:
this.Visible=true;
notifyIcon1.Visible=false;
加一个NotifyIcon控件
设置Icon选项,选择一个Icon图标。(QQ目录下搜索一下.ICO,找个企鹅弄上去)
这样你的程序运行的时候右下方就有图标了
控制notifyIcon1的Visible属性让它在右下方隐藏/显示
——————————————————————
楼主可曾测试过代码?我说的就是那效果。
要隐藏窗体
this.Visible=false;不就隐藏掉了?
最小化事件:
this.Visible=false;
notifyIcon1.Visible=true;
恢复事件:
this.Visible=true;
notifyIcon1.Visible=false;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private MyFormSettings MySettings = new MyFormSettings();
private void Form1_Load(object sender, EventArgs e)
{//读取保存的窗体信息
int MyLeft = Convert.ToInt16(MySettings.MyLeft);
int MyTop = Convert.ToInt16(MySettings.MyTop);
this.Location = new Point(MyLeft, MyTop);
int MyWidth = Convert.ToInt16(MySettings.MyWidth);
int MyHeight = Convert.ToInt16(MySettings.MyHeight);
this.Size = new Size(MyWidth, MyHeight);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{//保存关闭前的窗体信息
MySettings.MyLeft=this.Location.X.ToString();
MySettings.MyTop=this.Location.Y.ToString();
MySettings.MyWidth = this.Width.ToString();
MySettings.MyHeight = this.Height.ToString();
MySettings.Save();
}
}
sealed class MyFormSettings : ApplicationSettingsBase
{
[UserScopedSettingAttribute()]
public String MyLeft
{
get { return (String)this["MyLeft"]; }
set { this["MyLeft"] = value; }
}
[UserScopedSettingAttribute()]
public String MyTop
{
get { return (String)this["MyTop"]; }
set { this["MyTop"] = value; }
}
[UserScopedSettingAttribute()]
public String MyWidth
{
get { return (String)this["MyWidth"]; }
set { this["MyWidth"] = value; }
}
[UserScopedSettingAttribute()]
public String MyHeight
{
get { return (String)this["MyHeight"]; }
set { this["MyHeight"] = value; }
}
}
}
再修改一下吧,这个的位置是左顶部!
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private MyFormSettings MySettings = new MyFormSettings();
private void Form1_Load(object sender, EventArgs e)
{//读取保存的窗体信息
int MyLeft = Convert.ToInt16(MySettings.MyLeft);
int MyTop = Convert.ToInt16(MySettings.MyTop);
this.Location = new Point(MyLeft, MyTop);
int MyWidth = Convert.ToInt16(MySettings.MyWidth);
int MyHeight = Convert.ToInt16(MySettings.MyHeight);
this.Size = new Size(MyWidth, MyHeight);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{//保存关闭前的窗体信息
MySettings.MyLeft=this.Location.X.ToString();
MySettings.MyTop=this.Location.Y.ToString();
MySettings.MyWidth = this.Width.ToString();
MySettings.MyHeight = this.Height.ToString();
MySettings.Save();
}
}
sealed class MyFormSettings : ApplicationSettingsBase
{
[UserScopedSettingAttribute()]
public String MyLeft
{
get { return (String)this["MyLeft"]; }
set { this["MyLeft"] = value; }
}
[UserScopedSettingAttribute()]
public String MyTop
{
get { return (String)this["MyTop"]; }
set { this["MyTop"] = value; }
}
[UserScopedSettingAttribute()]
public String MyWidth
{
get { return (String)this["MyWidth"]; }
set { this["MyWidth"] = value; }
}
[UserScopedSettingAttribute()]
public String MyHeight
{
get { return (String)this["MyHeight"]; }
set { this["MyHeight"] = value; }
}
}
}
再修改一下吧,这个的位置是左顶部!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1,编写主窗体 SizeChanged 事件
private void FrmMain_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
}
}
2,编写notifylicon对象事件,这个可以发挥了
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Minimized;
this.Hide();
}
else
{
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
}
}
private void FrmMain_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
}
}
2,编写notifylicon对象事件,这个可以发挥了
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Minimized;
this.Hide();
}
else
{
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把程序写在 #region 和 #endregion 之间 就可以
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个要手工动代码~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询