一个中午没睡!!!大仙们来解惑

qinjingfeng 2007-06-12 02:41:40
我想做的是FROM1中 Button点击事件后 右下角逐显一个小窗口,2秒后渐隐

我是这么做的 Button中 From2 f2=new From2() ; f2.show();

public From2()
{
InitializeComponent();
this.Opacity = 0.01
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - 150, Screen.PrimaryScreen.WorkingArea.Height);//From2的高和宽都是150-----//控制窗口在右下角显示
}


private void pshow_Tick(object sender, EventArgs e)
{
if (this.Opacity < 1)
{
this.Opacity += 0.02;
}
else
{
this.pshow.Enabled = false;
this.pmid.Enabled = true;

}
}

private void pmid_Tick(object sender, EventArgs e)
{
this.pmid.Enabled = false;
this.phide.Enabled = true;

}

private void phide_Tick(object sender, EventArgs e)
{
if (this.Opacity > 0.01)
{
this.Opacity -= 0.02;
}
else
{
this.phide.Enabled = false;
this.Hide();
this.Close();
}
}


运行后 点Button后,一点反应都没有 可是如果把 this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - 150, Screen.PrimaryScreen.WorkingArea.Height); 去掉就能实现功能,可是窗口位置就得不到控制了
应该怎么办?
...全文
304 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Macosx 2007-06-15
  • 打赏
  • 举报
回复
楼主你有没有试我的代码 那个已经实现了
qinjingfeng 2007-06-15
  • 打赏
  • 举报
回复
- -
AhJo 2007-06-13
  • 打赏
  • 举报
回复
关注
qinjingfeng 2007-06-12
  • 打赏
  • 举报
回复
- -
YUAN168 2007-06-12
  • 打赏
  • 举报
回复
用一个Time控件来做吧...

time_timer()
{
form1.width=-20;
form1.height=-100;
..........
if (form1.width=10)
{
form1.hide();
}
}
qinjingfeng 2007-06-12
  • 打赏
  • 举报
回复
this.Opacity = 0.01 是必须的 我是想让它逐渐显示出来

this.StartPosition = FormStartPosition.Manual; 已经在属性里设置过了!
Macosx 2007-06-12
  • 打赏
  • 举报
回复
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.Opacity = 0.01;
this.Width = this.Height = 150;
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - 150, Screen.PrimaryScreen.WorkingArea.Height-150);//From2的高和宽都是150-----//控制窗口在右下角显示
}

private DateTime startTime;

private void timer_Tick(object sender, EventArgs e)
{
TimeSpan duration = DateTime.Now - startTime;
int milliSeconds = duration.Seconds * 1000 + duration.Milliseconds;
if (milliSeconds > 4000)
{
timer.Enabled = false;
this.Close();
}
this.Opacity = (double)(2000 - Math.Abs(milliSeconds - 2000)) / 2000;
this.textBox1.AppendText(milliSeconds.ToString() + System.Environment.NewLine);
}

private void Form2_Load(object sender, EventArgs e)
{
startTime = DateTime.Now;
timer.Enabled = true;
}
}
Macosx 2007-06-12
  • 打赏
  • 举报
回复
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.Opacity = 0.01;
this.Width = this.Height = 150;
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - 150, Screen.PrimaryScreen.WorkingArea.Height-150);//From2的高和宽都是150-----//控制窗口在右下角显示
}

private DateTime startTime;

private void timer_Tick(object sender, EventArgs e)
{
TimeSpan duration = DateTime.Now - startTime;
int milliSeconds = duration.Seconds * 1000 + duration.Milliseconds;
if (milliSeconds > 4000)
{
timer.Enabled = false;
this.Close();
}
this.Opacity = (double)(2000 - Math.Abs(milliSeconds - 2000)) / 2000;
this.textBox1.AppendText(milliSeconds.ToString() + System.Environment.NewLine);
}

private void Form2_Load(object sender, EventArgs e)
{
startTime = DateTime.Now;
timer.Enabled = true;
}
}
Macosx 2007-06-12
  • 打赏
  • 举报
回复
大师的错别字很多阿
你把窗体设成this.Opacity = 0.01 当然啥也看不着了
this.Opacity = 1.00
设置起始位置还需要加上
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - 150, Screen.PrimaryScreen.WorkingArea.Height-150);//From2的高和宽都是150-----//控制窗口在右下角显示
qinjingfeng 2007-06-12
  • 打赏
  • 举报
回复
- -!

110,534

社区成员

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

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

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