如何在我的应用程序中添加吐司样式弹出窗口?

编程入门 行业动态 更新时间:2024-10-19 11:54:01
本文介绍了如何在我的应用程序中添加吐司样式弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个在任务栏中运行的应用程序。当用户单击该应用程序时,它将弹出等。当我的一个朋友登录时,我想要的功能与MSN中的功能类似。显然,这是一个吐司弹出窗口吗? 我基本上希望每20分钟从任务栏上的应用程序中弹出吐司样式弹出的东西。

I have created an application that runs in the taskbar. When a user clicks the application it pops up etc. What I would like is similar functionality to that in MSN when one of my friends logs in. Apparently this is know as a toast popup? I basically want something to popup from every 20 minutes toast style fom the application in the taskbar.

我现有的应用程序是使用用C#编写的winforms。 3.5

My existing application is winforms based written in C# with 3.5

推荐答案

这很简单。您只需要在窗口外的区域中设置窗口并设置其位置的动画效果,直到完全可见即可。下面是示例代码:

This is pretty simple. You just need to set window in off-screen area and animate it's position until it is fully visible. Here is a sample code:

public partial class Form1 : Form { private Timer timer; private int startPosX; private int startPosY; public Form1() { InitializeComponent(); // We want our window to be the top most TopMost = true; // Pop doesn't need to be shown in task bar ShowInTaskbar = false; // Create and run timer for animation timer = new Timer(); timer.Interval = 50; timer.Tick += timer_Tick; } protected override void OnLoad(EventArgs e) { // Move window out of screen startPosX = Screen.PrimaryScreen.WorkingArea.Width - Width; startPosY = Screen.PrimaryScreen.WorkingArea.Height; SetDesktopLocation(startPosX, startPosY); base.OnLoad(e); // Begin animation timer.Start(); } void timer_Tick(object sender, EventArgs e) { //Lift window by 5 pixels startPosY -= 5; //If window is fully visible stop the timer if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height) timer.Stop(); else SetDesktopLocation(startPosX, startPosY); } }

更多推荐

如何在我的应用程序中添加吐司样式弹出窗口?

本文发布于:2023-11-11 07:26:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577763.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:吐司   应用程序   弹出窗口   样式   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!