• 0

[C#] Remove Titlebar/Close Button


Question

19 answers to this question

Recommended Posts

  • 0

Try this:

  Quote
private const int WS_DLGFRAME = 0x400000;

protected override System.Windows.Forms.CreateParams CreateParams {

get {

CreateParams cp = base.CreateParams;

cp.Style = cp.Style & !WS_DLGFRAME;

return cp;

}

}

I don't know if it'll work (it's translated to C# from VB)

  • 0

I think you need to turn off MaximizeBox, MinimizeBox, and ControlBox in addition to setting FormBorderStyle to none.

There's an example in the MSDN article for ControlBox: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.controlbox.aspx

  • 0
  On 15/04/2011 at 22:24, Gabureiru said:

Form -> FormBorderStyle = None

Doesn't keep an aero border

  On 15/04/2011 at 22:25, Jan said:

Try this:

I don't know if it'll work (it's translated to C# from VB)

That doesn't keep the aero border :(

  • 0
  Quote
[DllImport("uxtheme.dll")]

public static extern int SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, uint size);

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, WTA_NONCLIENT, ref wta, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS)));

Try this.

  • 0
  On 15/04/2011 at 22:31, GreyWolf said:

! is ~ in C#

Try turning off the "boxes" I suggested but leave FormBorderStyle alone.

I've already done that, and that code work's ish now i use the "~" operand. It removes the title bar, but keeps a pure white border, not aero :(.

  • 0
  On 15/04/2011 at 22:35, GreyWolf said:

No need for any weirdness...

form.ControlBox = false;

form.MaximizeBox = false;

form.MinimizeBox = false;

form.Text = "";

:)

EDIT: Here is the result using that:

post-175510-0-34108500-1302907156.png

I do that and get the picture below;

  On 15/04/2011 at 22:36, Jan said:

Can you post some screenshots showing the border please?

sure;

4e176ca5d6bf8097d44be9f23f686684.png

  • 0
  On 15/04/2011 at 23:00, Xerax said:

4e176ca5d6bf8097d44be9f23f686684.png

KK, turn your Form Borderstyle in your form properties to the default. (Sizable)

Set ControlBox property to False

Set Locked Property to True

Set Text to (empty)

  • 0
  On 15/04/2011 at 23:41, firey said:

KK, turn your Form Borderstyle in your form properties to the default. (Sizable)

Set ControlBox property to False

Set Locked Property to True

Set Text to (empty)

It looks the same as it does in that image. :/ It might be windows 8, but i can't see why it would be.

  • 0
  On 15/04/2011 at 23:48, Xerax said:

It looks the same as it does in that image. :/ It might be windows 8, but i can't see why it would be.

Hmm.. what visual studio ya running? I don't have 8 installed.. but It's possible Aero interacts with applications differently...

I did exactly what I told you, and was able to get the expected result (thin glass border et all)

  • 0
  On 15/04/2011 at 23:49, firey said:

Hmm.. what visual studio ya running? I don't have 8 installed.. but It's possible Aero interacts with applications differently...

I did exactly what I told you, and was able to get the expected result (thin glass border et all)

VS2010, Profession x86 (via Dreamspark).

Yeah, it could be, due to the introduction of the aerolite(metro) themes. Weird.

  • 0
  On 15/04/2011 at 23:54, Xerax said:

VS2010, Profession x86 (via Dreamspark).

Yeah, it could be, due to the introduction of the aerolite(metro) themes. Weird.

Hmm, I have 2010 installed too, so I know it's not that. I would have to wager it on the Aerolite... but as a test.. try a new project.. don't change ANY settings except the ones I listed, see if it works.

  • 0
  On 15/04/2011 at 23:56, firey said:

Hmm, I have 2010 installed too, so I know it's not that. I would have to wager it on the Aerolite... but as a test.. try a new project.. don't change ANY settings except the ones I listed, see if it works.

aha! It workes! I'll just port my code into this project. Thank you all so very much :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.