Ry-
Ry-

Reputation: 224862

Remove the title bar but keep the control box?

I'm overriding the CreateParams property in my form to draw a custom oversized titlebar:

Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams
    Get
        CreateParams = MyBase.CreateParams
        CreateParams.Style = CInt(CreateParams.Style And Not &HC00000L) 'WS_CAPTION
    End Get
End Property

And I've overridden WndProc to allow the form to be dragged:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc(m)

    If m.Msg = &H84 AndAlso m.Result.ToInt32() = 1 Then m.Result = New IntPtr(2)
End Sub

But the control box (close and minimize) disappears. Is there any way to keep the control box and the text in the taskbar, but remove the usual title?

Upvotes: 0

Views: 1103

Answers (3)

seri
seri

Reputation: 322

If I understood you right, you want to hide the title (and maybe the icon) from the titlebar, but not from the taskbar, just like the Vista/7 Explorer window.

This should help you: MSDN Forums Use this method with your preferred WTA_OPTIONS (should be 0x03) in pvAttribute.

Upvotes: 2

Hans Passant
Hans Passant

Reputation: 941218

You overrode the creation parameters to get a window without a title bar. Implementing support for WM_NCHITTEST was correct, there wouldn't be another way for the user to move the window around.

You don't have to override CreateParams to get this behavior. Just set the ControlBox property to False, the Text property to an empty string. What you want is hard to guess. If you don't want to lose the buttons on the title bar then just don't set ControlBox to False. "Unusual title" is very hard to guess too, what you see there is just the value of the Text property. Set it to an empty string if you don't want a title.

Upvotes: 0

David Heffernan
David Heffernan

Reputation: 612794

Once you elect to draw the non-client area yourself, you have to draw it all. There are no hybrid options.

Upvotes: 1

Related Questions