Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. "Minimize to tray" button in title bar

"Minimize to tray" button in title bar

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josefg
    wrote on last edited by
    #1

    Hi, How do I add a "Minimize to tray" button in the title bar of a form? Thanks, Josef

    H J 2 Replies Last reply
    0
    • J josefg

      Hi, How do I add a "Minimize to tray" button in the title bar of a form? Thanks, Josef

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The .NET Framework base class libraries do not contain functionality for working with the non-client areas of a window frame (other than setting the caption, setting the border style, and showing or hiding the control, minimize, maximize, adn restore buttons). In order to do this, you have to go back to Win32 practices of handling notification messages, so Win32 programming experience will help. You can find an old discussion of the process here: http://www.dotnet247.com/247reference/msgs/35/178321.aspx[^].

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • J josefg

        Hi, How do I add a "Minimize to tray" button in the title bar of a form? Thanks, Josef

        J Offline
        J Offline
        John Fisher
        wrote on last edited by
        #3

        There are two alternatives to Heath's reply, but his suggestion is the best. Alternative 1: Show absolutely none of the border area (there are properties in Windows Forms that you can use to hide them). Then, draw all the content you want on your own, putting normal buttons wherever you want them. The problem is that you must handle "hit testing" in order to let the user drag or resize the window, since Windows no longer does that work for you. There are several places to find information about that. Look to handle the WM_NCHITTEST message. Alternative 2: Create a separate form that floats over your main window. It would contain only the button(s) that you desire, with no border or spacing. Once that window is created, you can manually position it to sit wherever you like. The problem is that the window is free-floating, so you need to reposition it every time your main form is moved or resized. This is the ugliest solution, since the users can see this button lagging while the rest of the window moves nicely. John
        "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups