popup message on bottom right of screen
im not sure how to explian this but here is an e.g..
Msn messenger, when someone signs in you see a box popup bottom right of the screen showing 'user has signed in' etc
i want a simple popup like this to appear in the bottom right screen for 2 seconds, any one know how to do this guys?
or an alternative is something which appears on top of everything like a msgbox? but i dont know if this is possible
Re: popup message on bottom right of screen
Create a form with all the options you want, then make it always on top.
Re: popup message on bottom right of screen
There is a good example project in the CodeBank forum by wokawidget. Its in Badger Messenger and MSN Clone projects by him.
Re: popup message on bottom right of screen
To make a window on top
VB Code:
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub Form_Activate()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
'Set the window position to topmost
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
Re: popup message on bottom right of screen
hey andrew thanks, so lets say a user has 20 applications open, that form wil appear on the screen infront of them, when activated?
Re: popup message on bottom right of screen
Just put this together, so all you need to do is change the timers interval for different speeds. Should give you an idea as to how to do it.
VB Code:
Private Sub Form_Load()
Me.Move Screen.Width - Me.Width, Screen.Height
End Sub
Private Sub Timer1_Timer()
Me.Top = Me.Top - i
' 9000
i = i + 30
If Me.Top < Screen.Height - Me.Height Then
Timer1.Enabled = False
End If
End Sub
Re: popup message on bottom right of screen
thanks jmac, but when i ran that i didnt see nothing :confused:
Re: popup message on bottom right of screen
Quote:
Originally Posted by Pouncer
hey andrew thanks, so lets say a user has 20 applications open, that form wil appear on the screen infront of them, when activated?
yes
And just adding ontop of Jmacp's code, if you want to get the startbar height use
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
'-------------------------------------
Dim R As RECT
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect tWnd, R
Then use (R.Bottom - R.Top)
Re: popup message on bottom right of screen
Quote:
Originally Posted by Pouncer
thanks jmac, but when i ran that i didnt see nothing :confused:
Did you put a timer on the form ? If not set its interval to say 1.
Re: popup message on bottom right of screen
yep, i ran it, and nothing happens,
what should happen? :confused:
when i click on the form1 fromt the taskbar, i get an error on line
Me.Top = Me.Top - i
saying the form cant be moved or sized while minimized/maximised :confused:
Re: popup message on bottom right of screen
for jmac's code to work, put a in the declarations of the form
Re: popup message on bottom right of screen
ahhh yes, thats exactly what im looking for, thanksss!!!
and what about closing the form after 5 seconds?
Re: popup message on bottom right of screen
hey andrew about the
R.Bottom - R.Top
where can i put that mate?
because i increaed by taskbar height to double and form gets cut of in the bottom right
Re: popup message on bottom right of screen
I just changed Jmacp's a bit (i hope you don't mind) so now it rises up and after 5 sec it drops down and unloads.
You'll need 2 timers
VB Code:
Dim i As Long
Dim dir As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Sub Form_Load()
Me.Move Screen.Width - Me.Width, Screen.Height
dir = -1
Timer1.Interval = (1000 / 16)
Timer2.Interval = 5000
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
On Error Resume Next 'In case you minize the form
Dim R As RECT
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect tWnd, R
Me.Top = Me.Top + (i * dir)
' 9000
i = i + 30
If Me.Top < Screen.Height - Me.Height - (R.Bottom - R.Top) Then
Timer1.Enabled = False
Timer2.Enabled = True
ElseIf Me.Top > Screen.Height Then
Unload Me
End If
End Sub
Private Sub Timer2_Timer()
dir = 1
Timer1.Enabled = True
Timer2.Enabled = False
End Sub
Re: popup message on bottom right of screen
andrew exactly what im looking for, very nice
i tested your code but when i increase my taskbar height, the form cuts off
:confused:
Re: popup message on bottom right of screen
Increase the height while the form is visible and steady in one spot or moving?
Re: popup message on bottom right of screen
I edited my above post to fix the problem
Re: popup message on bottom right of screen
thanks andrew but any idea why it doesnt work when my program is in the system tray
Re: popup message on bottom right of screen
I have no idea, when i noramally use it i have the main program, the popup menu form and a form especially made for the system tray, so everything is seperate.
Re: popup message on bottom right of screen
ok no problem thanks for your help, by the way
if i call this form from another form multiple times would it give errors?
Re: popup message on bottom right of screen
Quote:
Originally Posted by Pouncer
ok no problem thanks for your help, by the way
if i call this form from another form multiple times would it give errors?
Probably not, but you would have to test that to be sure.
To be perfectly safe, if it isn't in use, then I would unload it.
Re: popup message on bottom right of screen
at first Thanks for all Supporters in this UseFul Forum.
I have already started search for this Method and i tried it ti works well with me also when the program is in the system tray.
-------------
But the Form doesnt appear in the same Position if it will apear more than one time
By the way at first Run i got un error with this:
tWnd = FindWindow("Shell_TrayWnd", vbNullString) .. Error is tWnd is not define
so i just tried to declare it as String, single and long
i got the same result the window doesnt move to the same position
,,,