Click here to Skip to main content
15,884,629 members
Articles / Desktop Programming / Windows Forms

Certified For Vista: How to ensure an application gets certified.

Rate me:
Please Sign up or sign in to vote.
4.89/5 (81 votes)
16 Apr 200712 min read 169K   738   149  
Do you want your applications to be approved by Microsoft to run on Windows Vista? This article explains how.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace DataInterface.Controls.Vista
{
    /// <summary>
    /// Button control in the style of a Vista command link (works on Vista only)
    /// </summary>
    public class CommandLink : System.Windows.Forms.Button
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public CommandLink(): base()
        {
            //To make the command link work, the FlatStyle has to be set to System on Vista.
            if (Global.RunningVistaOrLater())
                base.FlatStyle = FlatStyle.System;
            else
                base.FlatStyle = FlatStyle.Flat;
            this.ShowShield = false;
        }

        /// <summary>
        /// Gets or Sets the flat style of the button
        /// </summary>
        public new System.Windows.Forms.FlatStyle FlatStyle
        {
            get
            {
                return base.FlatStyle;
            }
            set
            {
                //Don't allow the FlatStyle to be changed if we are running Vista
                if (!Global.RunningVistaOrLater())
                    base.FlatStyle = value;
            }
        }

        /// <summary>
        /// Override for CreateParams that sets this button to be a command link style button
        /// </summary>
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.Style |= Global.BS_COMMANDLINK;
                return (cp);
            }
        }
    
        private bool showShield;
        /// <summary>
        /// Property that indicates whether or not to display the shield icon on the control
        /// </summary>
        public bool ShowShield
        {
            get
            {
                return this.showShield;
            }
            set
            {
                this.showShield = value;
                Global.SetShield(this, value);
            }
        }

        private string note;
        /// <summary>
        /// Gets or sets the note text that is displayed on the command link button
        /// </summary>
        public string Note
        {
            get
            {
                return this.note;
            }
            set
            {
                this.note = value;
                Global.SetNote(this, value);
            }
        }
    }
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
Simon Williams BEng, MCP
Senior Developer with Data Interface Ltd.

Comments and Discussions