popup message on bottom right of screen-VBForums
Results 1 to 22 of 22

Thread: popup message on bottom right of screen

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: popup message on bottom right of screen

    Create a form with all the options you want, then make it always on top.

  3. #3
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,113

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: popup message on bottom right of screen

    To make a window on top

    VB Code:
    1. Const HWND_TOPMOST = -1
    2. Const HWND_NOTOPMOST = -2
    3. Const SWP_NOSIZE = &H1
    4. Const SWP_NOMOVE = &H2
    5. Const SWP_NOACTIVATE = &H10
    6. Const SWP_SHOWWINDOW = &H40
    7. 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)
    8.  
    9. Private Sub Form_Activate()
    10.     'KPD-Team 1998
    11.     'URL: [url]http://www.allapi.net/[/url]
    12.     'E-Mail: [email]KPDTeam@Allapi.net[/email]
    13.     'Set the window position to topmost
    14.     SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    15. End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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?

  6. #6
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,958

    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:
    1. Private Sub Form_Load()
    2.  
    3.     Me.Move Screen.Width - Me.Width, Screen.Height
    4.  
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8.  
    9.     Me.Top = Me.Top - i
    10.     ' 9000
    11.     i = i + 30
    12.     If Me.Top < Screen.Height - Me.Height Then
    13.         Timer1.Enabled = False
    14.        
    15.     End If
    16.  
    17. End Sub

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: popup message on bottom right of screen

    thanks jmac, but when i ran that i didnt see nothing

  8. #8
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    3. '-------------------------------------
    4. Dim R As RECT
    5.  
    6.     tWnd = FindWindow("Shell_TrayWnd", vbNullString)
    7.     GetWindowRect tWnd, R
    Then use (R.Bottom - R.Top)

  9. #9
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,958

    Re: popup message on bottom right of screen

    Quote Originally Posted by Pouncer
    thanks jmac, but when i ran that i didnt see nothing
    Did you put a timer on the form ? If not set its interval to say 1.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: popup message on bottom right of screen

    yep, i ran it, and nothing happens,

    what should happen?

    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

  11. #11
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: popup message on bottom right of screen

    for jmac's code to work, put a
    VB Code:
    1. dim i as long
    in the declarations of the form

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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?

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  14. #14
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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:
    1. Dim i As Long
    2. Dim dir As Long
    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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    10. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    11.  
    12. Private Sub Form_Load()
    13.     Me.Move Screen.Width - Me.Width, Screen.Height
    14.     dir = -1
    15.     Timer1.Interval = (1000 / 16)
    16.     Timer2.Interval = 5000
    17.     Timer2.Enabled = False
    18. End Sub
    19.  
    20. Private Sub Timer1_Timer()
    21. On Error Resume Next    'In case you minize the form
    22.  
    23. Dim R As RECT
    24.  
    25. tWnd = FindWindow("Shell_TrayWnd", vbNullString)
    26. GetWindowRect tWnd, R
    27.  
    28.  
    29.     Me.Top = Me.Top + (i * dir)
    30.     ' 9000
    31.     i = i + 30
    32.     If Me.Top < Screen.Height - Me.Height - (R.Bottom - R.Top) Then
    33.         Timer1.Enabled = False
    34.         Timer2.Enabled = True
    35.     ElseIf Me.Top > Screen.Height Then
    36.         Unload Me
    37.     End If
    38.  
    39. End Sub
    40.  
    41. Private Sub Timer2_Timer()
    42. dir = 1
    43. Timer1.Enabled = True
    44. Timer2.Enabled = False
    45. End Sub
    Last edited by Andrew G; Dec 28th, 2005 at 06:48 PM.

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  16. #16
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Other side of town from si_the_geek
    Posts
    7,171

    Re: popup message on bottom right of screen

    Increase the height while the form is visible and steady in one spot or moving?


    Has someone helped you? Then you can Rate their helpful post.

  17. #17
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: popup message on bottom right of screen

    I edited my above post to fix the problem

  18. #18

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  19. #19
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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.

  20. #20

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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?

  21. #21
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  22. #22
    Addicted Member
    Join Date
    Nov 2005
    Posts
    153

    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

    ,,,
    Last edited by _Conan_; Dec 29th, 2005 at 01:06 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.