右下角弹出消息框

打开QQ的时候,QQ新闻弹出窗体在屏幕的右下角就会慢慢升起一个小窗口,占用的地方不大,可以起到提示的作用。下面就让我们来看看,怎样用系统API来轻松实现这个功能。

 

代码
       private int currentX;//横坐标      
        private int currentY;//纵坐标      
        private int screenHeight;//屏幕高度      
        private int screenWidth;//屏幕宽度 

        
int AW_ACTIVE = 0x20000//激活窗口,在使用了AW_HIDE标志后不要使用这个标志   
        int AW_HIDE = 0x10000;//隐藏窗口   
        int AW_BLEND = 0x80000;// 使用淡入淡出效果   
        int AW_SLIDE = 0x40000;//使用滑动类型动画效果,默认为滚动动画类型,当使用AW_CENTER标志时,这个标志就被忽略   
        int AW_CENTER = 0x0010;//若使用了AW_HIDE标志,则使窗口向内重叠;否则向外扩展   
        int AW_HOR_POSITIVE = 0x0001;//自左向右显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志   
        int AW_HOR_NEGATIVE = 0x0002;//自右向左显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志   
        int AW_VER_POSITIVE = 0x0004;//自顶向下显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志   
        int AW_VER_NEGATIVE = 0x0008;//自下向上显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志

        [DllImport(
"user32.dll")]
        
private static extern bool AnimateWindow(IntPtr hwnd, int dateTime, int dwFlags);//hwnd窗口句柄.dateTime:动画时长.dwFlags:动画类型组合

        
private void Messages2_Load(object sender, EventArgs e)
        {
            Rectangle rect 
= Screen.PrimaryScreen.WorkingArea;
            screenHeight 
= rect.Height;
            screenWidth 
= rect.Width;
            currentX 
= screenWidth - this.Width;
            currentY 
= screenHeight - this.Height;
            
this.Location = new System.Drawing.Point(currentX, currentY);

            AnimateWindow(
this.Handle, 1000, AW_SLIDE | AW_VER_NEGATIVE);  
        }

 

 

posted @ 2010-03-22 12:58  nyzfl  阅读(538)  评论(0编辑  收藏  举报