求救高手!下班前要解决的问题!

linuxjava01 2007-08-31 01:02:23
现在有一个窗口,是ShowDialog出来的顶级窗口,现在想在这个窗口的按纽单击的时候弹出一副"正在处理,请稍等的动画",在事件处理结束之后自动关闭.

1.最好不用进度条控件
2.我自己的做法:在单击按纽之后兴建一个线程,在线程中弹出一个Form,Form里面加载picturebox.
这个方法一般时可以,只是在当前窗口为showdialog窗口的时候,新线程的动画窗口就被showdialog窗口覆盖了,有没有办法让动画窗口显示在showDialog窗口的上方不被覆盖?
...全文
593 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
cityhunter303 2007-09-01
  • 打赏
  • 举报
回复
up
mzh3511 2007-08-31
  • 打赏
  • 举报
回复
你应该在按钮的Mouse_down事件里写处理吧
tansheng719 2007-08-31
  • 打赏
  • 举报
回复
把图片再ShowDialog()出来不行么?
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
temp.Show();改成 temp.ShowDialog();
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
第二份代码也错了?
怎样的情况
calledeleven 2007-08-31
  • 打赏
  • 举报
回复
还是不行
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
错了
public static void ShowWaitBar(Form fm, bool flg)
{
m_form = fm;
m_flg = flg;

Thread t = new Thread(new ThreadStart(SetWaitSigh));
t.Start();
while(isContinue){
Thread.Sleep(1000);
}
}
private static bool isContinue=true;
private static void SetWaitSigh()
{
try
{
Form temp = new Form();
temp.FormBorderStyle = FormBorderStyle.None;

if (m_flg)
{
//form.Cursor = Cursors.WaitCursor;

//设置为等待状态
PictureBox pb = new PictureBox();
pb.SizeMode = PictureBoxSizeMode.AutoSize;
pb.Name = "pbUserWait";
pb.Image = Image.FromFile(@"D:\一期相关\ff.gif");

//计算坐标
//int x = temp.Width / 2 - pb.Width / 2;
//int y = temp.Height / 2 - pb.Height / 2;

//pb.Location = new Point(x, y);
temp.Height = pb.Height;
temp.Width = pb.Width;
temp.Controls.Add(pb);


//设置为最前端
temp.StartPosition = FormStartPosition.Manual;
temp.Location = new Point((m_form.Location.X + m_form.Width / 2-temp.Width/2), (m_form.Location.Y + m_form.Height / 2-temp.Height/2));
temp.Show();
temp.TopMost = true;
}
else
{

}
}
catch (Exception ex)
{
throw ex;
}
finnaly{
isContinue = false;
}
}
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
public static void ShowWaitBar(Form fm, bool flg)
{
m_form = fm;
m_flg = flg;

Thread t = new Thread(new ThreadStart(SetWaitSigh));
t.Start();
while(isContinue){
Thread.Sleep(1000);
}
}
private static bool isContinue=false;
private static void SetWaitSigh()
{
try
{
Form temp = new Form();
temp.FormBorderStyle = FormBorderStyle.None;

if (m_flg)
{
//form.Cursor = Cursors.WaitCursor;

//设置为等待状态
PictureBox pb = new PictureBox();
pb.SizeMode = PictureBoxSizeMode.AutoSize;
pb.Name = "pbUserWait";
pb.Image = Image.FromFile(@"D:\一期相关\ff.gif");

//计算坐标
//int x = temp.Width / 2 - pb.Width / 2;
//int y = temp.Height / 2 - pb.Height / 2;

//pb.Location = new Point(x, y);
temp.Height = pb.Height;
temp.Width = pb.Width;
temp.Controls.Add(pb);


//设置为最前端
temp.StartPosition = FormStartPosition.Manual;
temp.Location = new Point((m_form.Location.X + m_form.Width / 2-temp.Width/2), (m_form.Location.Y + m_form.Height / 2-temp.Height/2));
temp.Show();
temp.TopMost = true;
}
else
{

}
}
catch (Exception ex)
{
throw ex;
}

}
calledeleven 2007-08-31
  • 打赏
  • 举报
回复
能帖代码吗?
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
在t.Start();后面阻塞主线程,等t线程执行完再释放主线程;
用一个bool变量也可以做到
china0308 2007-08-31
  • 打赏
  • 举报
回复
study
calledeleven 2007-08-31
  • 打赏
  • 举报
回复
那怎么样能在执行的时候就显示出来?
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
你的线程这样肯定是要到按纽事件执行完之后才会显示出来
calledeleven 2007-08-31
  • 打赏
  • 举报
回复
画面能出来,但是画面是空的,要在按纽事件结束之后动画窗口里的控件才显示出来.
我现在要一点按纽动画窗口里的图片就能显示
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
写错
动画窗口.Owner = 顶级窗口;
就OK
Gummy 2007-08-31
  • 打赏
  • 举报
回复
将showdialog改用form不就得了~
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
你只要设置
顶级窗口.Owner = 顶级窗口;
就OK
kaishui_gu 2007-08-31
  • 打赏
  • 举报
回复
你不是有两个对话框吗?
一个是“ShowDialog出来的顶级窗口”,在点按钮的时候,显示“动画窗口”,是不是这样?
在顶级窗口中的按钮事件中添加:
动画窗口frm = new 动画窗口();
frm.Owner=this;
frm.Show();
MYINGBEI 2007-08-31
  • 打赏
  • 举报
回复
关注``
calledeleven 2007-08-31
  • 打赏
  • 举报
回复
public static void ShowWaitBar(Form fm, bool flg)
{
m_form = fm;
m_flg = flg;

Thread t = new Thread(new ThreadStart(SetWaitSigh));
t.Start();
}

private static void SetWaitSigh()
{
try
{
Form temp = new Form();
temp.FormBorderStyle = FormBorderStyle.None;

if (m_flg)
{
//form.Cursor = Cursors.WaitCursor;

//设置为等待状态
PictureBox pb = new PictureBox();
pb.SizeMode = PictureBoxSizeMode.AutoSize;
pb.Name = "pbUserWait";
pb.Image = Image.FromFile(@"D:\一期相关\ff.gif");

//计算坐标
//int x = temp.Width / 2 - pb.Width / 2;
//int y = temp.Height / 2 - pb.Height / 2;

//pb.Location = new Point(x, y);
temp.Height = pb.Height;
temp.Width = pb.Width;
temp.Controls.Add(pb);


//设置为最前端
temp.StartPosition = FormStartPosition.Manual;
temp.Location = new Point((m_form.Location.X + m_form.Width / 2-temp.Width/2), (m_form.Location.Y + m_form.Height / 2-temp.Height/2));
temp.Show();
temp.TopMost = true;
}
else
{

}
}
catch (Exception ex)
{
throw ex;
}
}
加载更多回复(8)

110,535

社区成员

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

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

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