Results 1 to 15 of 15

Thread: Minimize to tray with a button...

  1. #1

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Red face Minimize to tray with a button...

    Ok, one more...

    Should be one line of code, but MSDN Library doesn't seem to address it that I can find...maybe because it's so dead simple, any dork could figure it out.

    I just want a button click event to minimize the app to system tray and keep running in the background.

    Probably as simple as Me.MinimizeToTray or something stupid.

    Thanks,
    CP

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    Use the System.Windows.Forms.NotifyIcon object. You can add one to your form from the toolbox.

    A whole lot easier then the old vb6 ways.
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Re: Minimize to tray with a button...

    That's the second time you've referred to the old VB6, but I've never used any VB in my life, I am completely new to programming. I come from an HTML background. When I said n00b, I meant it in the truest form.



    So I'll goof around with the NotifyIcon a bit. It's definitely a start.

    Thanks.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    I was only referring how hard it "used" to be in VB6. Now with.NET its as simple as dragging and
    dropping the NotifySysTray object from the toolbox to your form.
    Then in the minimize of the form you set the notifyicon to visible. Not hard at all.
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    If need be I can write a demo of the SysTray.


    But of course

    Been there several times so it becomes boring.

    Disneyland, KnottsBerry Farm, Magic Mountain many many times.
    Santa Monica is usually too polluted or cold, I like OC beaches better
    Hollywood: Crused the Blvd back in the day (nothing but freaks now), Universal City Walk several times.
    California Speedway (Nascar), Dodger stadium, Anaheim Angeles Staduim (which my company is directly accross the street from).
    Las Vegas (only 265 miles away) many many times.
    San Francisco - last summer.
    Maui (Hawaii) - 1 1/2 years ago

    Most within the past 2 years.





    But I mostly enjoy driving to/from work with the top down from the Spring to the Fall.
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Re: Minimize to tray with a button...

    Hi all!
    Quick Question regarding the Tray Icon.
    I tryed it out as well but useing an existing program.
    Also, instead of using the minimize Box I'm using a button. I have noticed that when Minimizing my App. there is still part of the title bar visible just over the windows start button.
    Would you care to explain why that is??

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    Thats because you need to set the form's visibility to False when its minimized to the systray. Then when
    the icon is double-clicked or ? you restore the form and set the visibility back to True.
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Re: Minimize to tray with a button...

    I tryed that but all it will do is put the title bar back over the Start button. I'm confused.

  9. #9
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Re: Minimize to tray with a button...

    Never mind I did not set the Visible on top. I had it on the bottom of my code. It is working now!
    Thanks!

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    Doh! I made a demo for you. Anyways, here it is.
    Attached Files Attached Files
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Re: Minimize to tray with a button...

    UPS!
    Sorry about that!

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Minimize to tray with a button...

    No prob. Someone else may find it useful. Thats why I uploaded it anyways.
    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!
    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 i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Re: Minimize to tray with a button...

    kulrom, I was referring to RobDog with the VB6 comment, not you; sorry for the confusion.

    Rob - thanks for the sample code...I'll see how I can work it in. I need it to apply both to the minimize button AND a normal button, so I'll start with what you sent.

    CP
    www.desertstormrally.com

  14. #14
    Lively Member
    Join Date
    Oct 2005
    Posts
    123

    Re: Minimize to tray with a button...

    thnx for the demo robdog...

  15. #15
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    Re: Minimize to tray with a button...

    thx,
    I found out how to use the NotifyIcon, a little bit back no real use of it yet, cause all the examples i found were add a button here to make it happen, and i wanted it to work with the minimize form btn, then i found your example and it works like a charm thx alot man.

    ps.
    it was very easy to port to my proggie.

    thx

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