窗口打开关闭的动画效果

skysquall 2009-12-16 11:09:16
我想用计时器控制窗口位置及高宽来自己实现动画,实现那种关闭时收缩的效果,但是发现当调用this.close()时会有一个黑线框一闪而过,很难看,有没有人知道这个黑线框怎么来的?以及怎么把它去掉?
...全文
280 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
nixiang12 2009-12-16
  • 打赏
  • 举报
回复
...路过..
skysquall 2009-12-16
  • 打赏
  • 举报
回复
我是在wince上跑的Form,所以可能不一样,windows上黑线框看不出来好像,wince上就能看出来
ITDC_YiWang 2009-12-16
  • 打赏
  • 举报
回复
顶起
yaojian12 2009-12-16
  • 打赏
  • 举报
回复
LZ有使用到不规则的皮肤么?我以前在做一个类似QQ弹出窗口的时候因为用了不规则的窗口导致出现下面一条黑线(静止窗口不会出现,只出现在运动窗口中)
gxingmin 2009-12-16
  • 打赏
  • 举报
回复
我测试没有黑线框啊
 private void timer1_Tick(object sender, EventArgs e)
{
this.Width -= 10;
this.Height -= 10;

if (this.Width < 50 || this.Height < 50)
{
this.Width = 0;
this.Height = 0;
this.Close();
}

}
skysquall 2009-12-16
  • 打赏
  • 举报
回复
高度为0和宽度都为0时,再this.Close(),还是有黑线框
FormBorderStype=None,本来窗口就是无边的窗口
gxingmin 2009-12-16
  • 打赏
  • 举报
回复
你收缩到高度为0和宽度都为0时,再this.Close()看看
或者收缩到一定小时,把窗体的标题栏设置None,即FormBorderStype=None看看
ITJaneLiu 2009-12-16
  • 打赏
  • 举报
回复
帮顶
rqx110 2009-12-16
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Utility
{
/// <summary>
/// Base form class that provides fading/sliding effects on open/close of the form.
/// </summary>
public abstract class FadeForm : Form
{
#region Win32

const int AW_HIDE = 0X10000;
const int AW_ACTIVATE = 0X20000;
const int AW_HOR_POSITIVE = 0X1;
const int AW_HOR_NEGATIVE = 0X2;
const int AW_SLIDE = 0X40000;
const int AW_BLEND = 0X80000;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int AnimateWindow
(IntPtr hwand, int dwTime, int dwFlags);

#endregion

#region Variables

private bool _UseSlideAnimation;

#endregion

#region Constructor

/// <summary>
/// Initializes a new instance of the <see cref="FadeForm"/> class.
/// </summary>
public FadeForm() : this(false) { }

/// <summary>
/// Initializes a new instance of the <see cref="FadeForm"/> class.
/// </summary>
/// <param name="useSlideAnimation">if set to <c>true</c> [use slide animation].</param>
public FadeForm(bool useSlideAnimation)
{
_UseSlideAnimation = useSlideAnimation;
}

#endregion

#region Overrides

/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
AnimateWindow(this.Handle, 1000, AW_ACTIVATE | (_UseSlideAnimation ? AW_HOR_POSITIVE | AW_SLIDE : AW_BLEND));
}

/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Form.Closing"/> event.
/// </summary>
/// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs"/> that contains the event data.</param>
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
base.OnClosing(e);
if (e.Cancel == false)
{
AnimateWindow(this.Handle, 1000, AW_HIDE | (_UseSlideAnimation ? AW_HOR_NEGATIVE | AW_SLIDE : AW_BLEND));
}
}

#endregion

}
}
an_ding 2009-12-16
  • 打赏
  • 举报
回复
提个思路,大家看看可不可以,加一个time,关闭窗口时,先不关闭,定时缩小窗口的大小,窗口的位置不变,当窗口大小为一个比较小的数值时,再关闭窗口。

110,534

社区成员

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

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

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