Results 1 to 5 of 5

Thread: How to Popup a Window near the Tray Icons, like the one in MSN Messenger...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Exclamation How to Popup a Window near the Tray Icons, like the one in MSN Messenger...

    Hi Guys,
    How should I Popup a Form near the Taskbar to notify a Message, like the one in MSN Messenger (a new window will popup when some person log in or when some New Message Arrives). Also it should be popped up upon the Taskbar. When the Taskbar is hidden then it should popup from the Bottom of the Screen. Do Anyone have any Idea of doing this...Thnx in advance.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can easilly simulate that. Create a form (make the size that you want to appear at the bottom), set it's BorderStyle property to None:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type RECT
    4.         Left As Long
    5.         Top As Long
    6.         Right As Long
    7.         Bottom As Long
    8. End Type
    9. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
    10. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    11. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    12.  
    13.  
    14. Private Sub Command2_Click()
    15.     Unload Me
    16. End Sub
    17.  
    18. Private Sub Form_Load()
    19.     Dim rec As RECT
    20.     Dim lngHwnd As Long
    21.     Dim lngWidth As Long
    22.     Dim lngHeight As Long
    23.    
    24.     lngHwnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
    25.     Call GetWindowRect(lngHwnd, rec)
    26.    
    27.     lngWidth = Me.ScaleX(Me.Width, vbTwips, vbPixels)
    28.     lngHeight = Me.ScaleY(Me.Height, vbTwips, vbPixels)
    29.    
    30.     Call MoveWindow(Me.hwnd, rec.Right - lngWidth, rec.Top - lngHeight, lngWidth, lngHeight, 1)
    31. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Exclamation How to Control the Speed of Appearence

    Hi Serge,
    Thnx for ur code. I got it working. But I need to Control the Speed of Appearence of the Window. ie., i want it to rise slowly Upwards. I hope you would've seen this effect in MSN Messenger. Is it Possible to get this. Thnx again.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Not a problem:
    VB Code:
    1. Private Type RECT
    2.         Left As Long
    3.         Top As Long
    4.         Right As Long
    5.         Bottom As Long
    6. End Type
    7. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
    8. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    9. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    10. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    11.  
    12. Public Sub TimeOut(p_sngInterval As Single)
    13.     Dim sngTimer As Single
    14.    
    15.     sngTimer = Timer
    16.     Do While Timer < sngTimer + p_sngInterval
    17.         DoEvents
    18.     Loop
    19. End Sub
    20.  
    21.  
    22. Private Sub Command2_Click()
    23.     Unload Me
    24. End Sub
    25.  
    26. Private Sub Form_Load()
    27.     Dim rec As RECT
    28.     Dim lngHwnd As Long
    29.     Dim lngWidth As Long
    30.     Dim lngHeight As Long
    31.     Dim lngPos As Long
    32.    
    33.     Me.Show
    34.     DoEvents
    35.    
    36.     lngHwnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
    37.     Call GetWindowRect(lngHwnd, rec)
    38.    
    39.     lngWidth = Me.ScaleX(Me.Width, vbTwips, vbPixels)
    40.     lngHeight = Me.ScaleY(Me.Height, vbTwips, vbPixels)
    41.    
    42.     lngPos = rec.Top - (rec.Bottom - rec.Top)
    43.    
    44.     Do Until lngPos <= rec.Top - lngHeight
    45.         Call MoveWindow(Me.hwnd, rec.Right - lngWidth, lngPos, lngWidth, lngHeight, 1)
    46.         DoEvents
    47.         TimeOut 0.1
    48.         lngPos = lngPos - 10
    49.     Loop
    50. End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Hi Serge, I did this with a Timer...

    Hi Serge,
    I tried this with a Timer and found it to be easier than ur code. Anyway Thanks a Lot for ur code.

    Option Explicit

    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type
    Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Dim rec As RECT
    Dim lngHwnd As Long
    Dim lngWidth As Long
    Dim lngHeight As Long, TempTop As Long, SecTop As Long

    Private Sub Command1_Click()
    Timer4.Enabled = True
    End Sub

    Private Sub Form_Activate()
    lngHwnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
    Call GetWindowRect(lngHwnd, rec)

    lngWidth = Me.ScaleX(Me.Width, vbTwips, vbPixels)
    lngHeight = Me.ScaleY(Me.Height, vbTwips, vbPixels)

    Call MoveWindow(Me.hwnd, rec.Right - lngWidth, rec.Top - lngHeight, lngWidth, lngHeight, 1)
    TempTop = Me.Top
    Me.Top = Me.Top + Me.Height
    Me.Left = Me.Left - 100
    End Sub

    Private Sub Timer1_Timer()
    Me.Top = Me.Top - 50
    If Me.Top <= TempTop Then
    Timer1.Enabled = False
    SecTop = Me.Top
    MMC.Command = "Close"
    End If
    End Sub

    Private Sub Timer4_Timer()
    Me.Top = Me.Top + 50
    If Me.Top = TempTop Then
    Timer4.Enabled = False
    Unload Me
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width