Removing or Editing Title Text

When you instance your Form, you assign it a name. The name becomes the Title Text of the Form as well. You can easily change the Title Text or the Forms Name if you want. Since they are two different properties, they can both be assigned a different value.

Since Forms can have a textured title bar instead of only a solid color, you might have a fancy title bar. What if you placed your own title bar text in your texture, and you don't need the title bar to display it's default? You can easily set the text to an empty string.

While this can be done during instancing, it is recommended not to do so. You should still provide a name during instancing and then clear the text afterwards. This way your Form still has some kind of internal name you can reference if you need to. If you choose to pass a null or empty string during instancing, a default name will be created. However there's no guarantee that the name provided won't already exist as well, which can throw you off when trying to find a Form later.

Lets set the Forms title bar text to empty.
        protected override void Initialize()
        {
            StandardForm form = new StandardForm(this, "New Form");
            this.Components.Add(form);

            //Force Form to not Move
            form.HasTitleBar = false;
            form.Text = String.Empty;

            base.Initialize();

            form.Show();
        }

This provides you with a Form that has not title bar or title text.
NotitleText1.png

You can set the text to empty and leave the title bar on if you want. This is useful if you have a custom title bar material you are going to use.
NoTitleText2.png

That can be achieved by using the Forms SetTitleMaterial method.

        protected override void Initialize()
        {
            StandardForm form = new StandardForm(this, "New Form");
            this.Components.Add(form);

            //Force Form to not Move
            form.Text = String.Empty;

            base.Initialize();

            //CustomTitleBar material imported via Content Pipeline
            form.SetTitleMaterial("CustomTitleBar");
            form.Show();
        }

Last edited Jan 19, 2012 at 11:23 PM by Scionwest, version 3

Comments

No comments yet.