纸盘通知弹出窗口 [英] Tray Notification Popup Window

查看:312
本文介绍了纸盘通知弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用VB.Net Windows应用程序.
我正在尝试创建一个显示在托盘菜单上方的弹出窗口应用程序.

表格1中的代码

Hi,

I am working on VB.Net Windows Application.
I am trying to create a popup window application that shows above tray menu.

Code in Form 1

'in button click event
Dim frm As New newRequest("some text")
frm.Show()




表格2中的代码




Code in Form 2

Dim receiveValue As String = "";

Public Sub New(ByVal str As String)
    MyBase.New()
    InitializeComponent()
    receiveValue = str
End Sub

Private Sub form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TopMost = True
    Label1.Text = str
    Me.Location = New Point(Screen.PrimaryScreen.Bounds.Width - Me.Width, Screen.PrimaryScreen.Bounds.Height)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If i = 200 Then Me.Close()
    Me.Location = New Point(Me.Location.X, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
    i += 1
End Sub

'set timer interval to 10




上面的代码工作正常,但是当我单击窗体1上的按钮时,将打开一个新窗体.当我再次单击表单1上的按钮时,然后再次打开一个表单,该表单将隐藏/覆盖先前的表单,即打开时覆盖了先前的表单.

在这里,我希望新表单可以在前一个表单的上方打开(例如G-Talk通知),但不要将其隐藏/重叠.




The above code is working fine but when I click the Button on Form 1, a new form opens up. When I click the Button on Form 1 again, then again a form opens up, which hides/overlaps the previous form i.e. opens up with covering the previous form.

Here on, I want that the new form shall be opened just above the previous form (like G-Talk notifications) but does not hide/overlap it.

推荐答案

在您的计时器的滴答声事件,您
In your Timer''s Tick event, you do
Me.Location = New Point(Me.Location.X, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)


您必须调整此代码以在想要显示的适当位置显示表单.您必须维护当前显示表单的内部列表,并使用此列表来确定新表单的显示位置.例如,如果已经显示了两个表单,那么您必须在已经显示的两个表单上方显示此表单.这样的东西


You must adjust this code to show the Form at the appropriate location you wish to show. You have to maintain an internal list of currently displayed forms and use this list to determine where the new form is shown. For example, if two forms are already shown, then you must show this form above the two forms already displayed. Something like this

Me.Location = New Point(Me.Location.X, Screen.PrimaryScreen.WorkingArea.Height - Me.Height - instanceCount * Me.Height)


其中instanceCount是一个静态变量(在VB中为Shared),用于保存先前实例的数量.


where instanceCount is a static (Shared in VB) variable that holds the count of previous instances.


我在这里找到了解决方法

http://www.vbforums.com/attachment.php?attachmentid=67735&d=1227757102 [ ^ ]

下载以上文件.它可以按我的需要
I found the solution here

http://www.vbforums.com/attachment.php?attachmentid=67735&d=1227757102[^]

Download above file. It works as i want


这篇关于纸盘通知弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆