Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Minimize window to system tray

, 8 Jul 2008
This article describes how you can write some simple code for minimizing a window to the system tray.
Minimize_2_System_Tray.zip
testApp
bin
Debug
MinimizeToTray.exe
MinimizeToTray.vshost.exe
Properties
Settings.settings
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="notifyIcon1.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAABAAIAEBAAAAEACABoBQAAJgAAABAQAAABACAAaAQAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEAB
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAGFcMAB4dVEAm5h/AKajjACloo0AnJiAAHp1UwBgWy0AX18fAHVy
        TQCzr54A39zXAOTh3QDm5OAA5+ThAOXi3gDh3tkAtbGgAHdyUABMTBkAfHhXAMnGvQDV0cwA1dLMAMrH
        vgB+elkATEwzAHl2UwDEwbcAxMC4AMG9swC4tKcAuraqAHBsSABfWi8AwsCxAMO/tgC2saYAtbClAKyn
        mAC3s6YAx8S4ANXTygDm5d8A/f38AM/MxQCYk34AYl0xAGxnQgDo5uIAubWpAKijlACnopMAoJuHAN3c
        0wD///8A1dPMAKeikgBtaEMAeXRVAOrp5QCblYMAjIduAO3t6ADg3tgAenVWAHhzUwDh39oAx8S5AI+I
        cwCYk3wA/v7+AO7t6gB6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8fX5/
        gIGCgoKCg4QAAAB1dnd4ODhIeXp7e3sHawAAbW5vODg4ODhwcXJycnMAYmNkOGVmZzg4OD1oaWlqa1ZX
        OFhZWltcODg4XV5fYGFLTE1OT09PUFE4OEhSU1RVQ0RFRkZGRkZHSDg4OElGSjw9ID4+Pj4+P0A4ODhB
        PkIxMjM0NDQ1Njc4ODg4OTo7ACQlJiYmJygpKissLS4vAAAcHR4eHh4eHh4eHyAhIgAAABUWFxgYGBgY
        GBcZGgAAAAAACgsMDQ4PEBESEwAAAAAAAAAAAgMEBQYHAAAAAAD4HwAA4AcAAMADAACAAQAAgAEAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAOAHAAD4HwAAKAAAABAAAAAgAAAAAQAgAAAA
        AABABAAAIi4AACIuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABdWDE0c29Im4iEYN2FgV38hYFe/IiE
        Yd90cEmdXFgzNwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAExMMwpwbUeeg39b/nl0Tv9iXDP/YVsx/2Fb
        Mf9iXDP/eXRP/4WBXv5ybkiiVVUqDAAAAAAAAAAAAAAAAExMGQp1cUvDenVR/2hiPP+RjnL/nJl//3x3
        Vv9jXTX/Y101/2NdNf9jXTX/e3dT/3dzTMdcXC4LAAAAAAAAAABvakSceHNR/4yIbf/u7ur/////////
        ///+/v7/z83B/3RuTf9nYT3/Z2E9/2dhPf96dVP/b2xFogAAAABgWzMye3ZW/Y2Jcf/5+fj/////////
        ///////////////////s6+f/gXxi/29qTP9vakz/b2pM/355Wf5hXDM3bmlDmH55YP/o5+P//////+Tj
        3v/CwLP/3dzU/////////////////+rp5f+AemP/eHJZ/3hyWf9+eF//b2xFnnZxUdmlopL//////8bE
        uP99d13/e3Va/3dxU/+4taP/////////////////09HJ/354YP+NiHT/iINv/3l0U993clL5y8m//+7t
        6f+Ff2b/g31k/4N9ZP+DfWT/f3hd/9jXzf////////////7+/v/Fwrb/8/Lw/4iCa/95c1T9eHNT+eHf
        2v/HxLn/j4hz/4+Ic/+PiHP/j4hz/4+Ic/+Yk3z//v7+/////////////////+7t6v+PiHP/enRV/Hl0
        Vdjq6eX/uLSn/5uVg/+blYP/m5WD/5uVg/+blYP/jIdu/+3t6P/////////////////g3tj/m5WD/3p1
        Vt5sZ0KW6Obi/7m1qf+oo5T/qKOU/6ijlP+nopP/oJuH/93c0///////////////////////1dPM/6ei
        kv9taEOcX1ovMMLAsf3Dv7b/trGm/7axpv+2sab/tbCl/6ynmP+3s6b/x8S4/9XTyv/m5d///f38/8/M
        xf+Yk37+Yl0xNAAAAAB5dlOZxMG3/8TAuP/EwLj/xMC4/8TAuP/EwLj/xMC4/8TAuP/EwLj/wb2z/7i0
        p/+6tqr/cGxIngAAAAAAAAAAX18fCHx4V8DJxr3/1dHM/9XSzP/V0sz/1dLM/9XSzP/V0sz/1dLM/9XR
        zP/Kx77/fnpZxExMMwoAAAAAAAAAAAAAAABfXx8IdXJNmLOvnv3f3Nf/5OHd/+bk4P/n5OH/5eLe/+He
        2f+1saD9d3JQnExMGQoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABhXDAveHVRlpuYf9imo4z4paKN+ZyY
        gNl6dVOYYFstMgAAAAAAAAAAAAAAAAAAAADwDwAAwAMAAIABAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAACAAQAAgAH//8AD///wD///
</value>
  </data>
  <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>124, 17</value>
  </metadata>
</root>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Elroy Dsilva
Software Developer
United States United States
Elroy is a software developer whose technical experitise and learning include programming languages such as C, C++ and C#. He loves writing simple technical articles and blogging whenever He finds some time for himself.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 8 Jul 2008
Article Copyright 2008 by Elroy Dsilva
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid