GONeale
GONeale

Reputation: 26484

Remove title bar text of a window but keep status bar text

I am working with Windows Forms, is it possible to create a window which has text in the status bar, but has no text in the title bar at the top of the application? (Largely because the standard title text which prints on my Aero glass I have implemented looks terrible as it's too high and I am drawing my own text title and obviously don't want the double up).

This solution (How to make a window have taskbar text but no title bar) is not satisfactory as I still wish to keep a FixedDialog window frame.

Thanks for your help all.

** I am aware of John's recommendation, but still seeking clearer direction, anybody feel free to put forward your ideas **

Upvotes: 2

Views: 2617

Answers (2)

Factor Mystic
Factor Mystic

Reputation: 26790

This should do it:

[DllImport("uxtheme.dll")]
public static extern int SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, uint size);

public enum WindowThemeAttributeType : uint
{
    /// <summary>Non-client area window attributes will be set.</summary>
    WTA_NONCLIENT = 1,
}

public struct WTA_OPTIONS
{
    public uint Flags;
    public uint Mask;
}
public static uint WTNCA_NODRAWCAPTION = 0x00000001;
public static uint WTNCA_NODRAWICON = 0x00000002;

WTA_OPTIONS wta = new WTA_OPTIONS() { Flags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON, Mask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON };

SetWindowThemeAttribute(this.Handle, WindowThemeAttributeType.WTA_NONCLIENT, ref wta, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS)));

Upvotes: 10

John
John

Reputation: 1094

What you are talking about would require subclassing to get into the guts of the application. Esentially you would be skinning your form by intercepting certain messages (like WM_PAINT etc.). It's not a simple thing to do if you've never worked at that level before.

Upvotes: -1

Related Questions