Click here to Skip to main content
15,891,941 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
VB
'in button click event
Dim frm As New newRequest("some text")
frm.Show()



Code in Form 2
VB
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



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.
Posted
Updated 3-Aug-11 19:37pm
v2

In your Timer's Tick event, you do
VB
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
VB
Me.Location = New Point(Me.Location.X, Screen.PrimaryScreen.WorkingArea.Height - Me.Height - instanceCount * Me.Height)

where instanceCount is a static (Shared in VB) variable that holds the count of previous instances.
 
Share this answer
 
Comments
kals84 4-Aug-11 1:29am    
This can be useful, but let suppose if 5 forms are shown there and if i close the first(bottom) form, how do 2,3,4,5 are slide down.
In your case they acquired the fixed position which i don't want.
[no name] 4-Aug-11 15:13pm    
The instanceCount variable always contains the number of shown forms. So if a form is hidden, the variable must be decremented.
I found the solution here

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

Download above file. It works as i want
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900