|
-
Aug 24th, 2001, 12:01 AM
#1
Thread Starter
Lively Member
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.
-
Aug 24th, 2001, 03:13 PM
#2
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:
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
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rec As RECT
Dim lngHwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
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)
End Sub
-
Aug 24th, 2001, 10:17 PM
#3
Thread Starter
Lively Member
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.
-
Aug 26th, 2001, 04:07 PM
#4
Not a problem:
VB Code:
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
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub TimeOut(p_sngInterval As Single)
Dim sngTimer As Single
sngTimer = Timer
Do While Timer < sngTimer + p_sngInterval
DoEvents
Loop
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rec As RECT
Dim lngHwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
Dim lngPos As Long
Me.Show
DoEvents
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)
lngPos = rec.Top - (rec.Bottom - rec.Top)
Do Until lngPos <= rec.Top - lngHeight
Call MoveWindow(Me.hwnd, rec.Right - lngWidth, lngPos, lngWidth, lngHeight, 1)
DoEvents
TimeOut 0.1
lngPos = lngPos - 10
Loop
End Sub
-
Aug 26th, 2001, 10:12 PM
#5
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|