Results 1 to 16 of 16

Thread: Form without titlebar, but with title text (to show in taskbar)?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Form without titlebar, but with title text (to show in taskbar)?

    Hey there,


    The main form in my application is a small form without a titlebar. I accomplished this by setting these properties:
    - ControlBox = False
    - MinimizeBox = False
    - MaximizeBox = False
    - Text = "" (empty)

    As long as the Text (title text) remains empty, the form has no title bar. Note that it still has a border so it can be resized (FormBorderStyle = Sizable, as usual, not None!)


    Now, because I have to keep the Text property empty, the taskbar button never shows any text... But I want to show text in the taskbar button!

    As far as I know, the only way to set the text on the taskbar button is using the forms Text property, but I cannot set that because the form will have a titlebar if I do...


    Is there no way around this?
    Can I have a form without a titlebar (caption, or whatever it's called), but still with text in the taskbar button?

  2. #2
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Yes there is, you could set the FormBorderStyle = None. Then set the Forms text to whatever you want.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Quote Originally Posted by Mal1t1a View Post
    Yes there is, you could set the FormBorderStyle = None. Then set the Forms text to whatever you want.
    But then I lose the border completely, which is not what I want. The form needs to be resizable. I suppose I could make it manually resizable (I know how, even got a codebank submission on the subject), but then I have to draw my own border, and I'd like to keep the normal windows border.

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Nick won't be satisfied with FormBorderStyle=None because he still wants a border for resizing -- just no title bar. @Nick, I think you need to set the Form's Region property to exclude the title bar. Parts outside the region will not be drawn, so the form can still have its text. Disclaimer: But I haven't tried it

    BB

  5. #5
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Form without titlebar, but with title text (to show in taskbar)?

    It doesn't seem to be possible if you don't want to draw your own border. You could always, just grab the picture of the border, and draw it onto the form, and set the Forms Region Property To be more Rectangular. But again, You are re-drawing it.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Quote Originally Posted by boops boops View Post
    Nick won't be satisfied with FormBorderStyle=None because he still wants a border for resizing -- just no title bar. @Nick, I think you need to set the Form's Region property to exclude the title bar. Parts outside the region will not be drawn, so the form can still have its text. Disclaimer: But I haven't tried it

    BB
    Hm, that's not ideal either, because
    1) I have to know exactly how large the border is (which can be different for different versions of windows, themes, etc),
    2) It looks crap. For some reason it seems to revert to the 'basic' theme on windows 7, so the borders look flat and all that. Also, the top looks crap because it's not a real border, just part of the titlebar...

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    I found this, but the conclusion was also to remove the entire border

    Is there really no other way? There must be some way to set the taskbar text, using some API perhaps?

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Well, I think I found a solution (it was in the link I posted previously after all).
    When I override the forms CreateParams property and remove the &HC00000 style (WS_CAPTION), then it seems to work.

    But, the thread (and also other threads) mention that this resulted in a 'different' border. I can't see a difference on windows 7, but I'm afraid the border will be different on Vista or XP maybe... I can't test it as I only have win7...

    Could anyone test this for me?
    All you need is to add this code to your form:
    Code:
    Protected Overrides ReadOnly Property CreateParams() As CreateParams
       Get
          Dim cp As CreateParams = MyBase.CreateParams
          cp.Style = cp.Style And Not &HC00000 ' WS_CAPTION
          Return cp
       End Get
    End Property
    and tell me if the border looks normal or not... Thanks!

  9. #9
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Form without titlebar, but with title text (to show in taskbar)?

    I'm running Windows XP SP3 on this computer, I tested that code, and it just did the exact same effect as setting the Form Border Style to None

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Quote Originally Posted by Mal1t1a View Post
    I'm running Windows XP SP3 on this computer, I tested that code, and it just did the exact same effect as setting the Form Border Style to None
    So that means there is no border at all? That's strange, because I still get a border:


    See, there is an ordinary looking border, no caption, and still a taskbar button text.

    This is exactly what I need, but judging from your post and the other thread, it doesn't work like this on XP..?

  11. #11
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Okay, well, with this code, I can not resize the form, but it does still give it a nice Border.

    Code:
    Protected Overrides ReadOnly Property CreateParams() As CreateParams
            Get
                Dim cp As CreateParams = MyBase.CreateParams
                cp.Style = -&HA00000 And cp.Style
                Return cp
            End Get
        End Property

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Quote Originally Posted by Mal1t1a View Post
    Okay, well, with this code, I can not resize the form, but it does still give it a nice Border.
    I'm starting to freak out slightly now ... That code gives me no border at all, like what you described with my code... Did MS really change this behavior completely in Win7??

  13. #13
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Hi Nick, I haven't followed all the ins and outs of the thread, but for what it's worth here's another off-the-wall idea. Set ShowInTaskbar to False and use another (invisible) form to show the taskbar button with text. Here's a quick example.
    vb.net Code:
    1. Public Class Form1
    2.  
    3.     Dim proxyForm As New Form
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         Me.ControlBox = False
    6.         Me.MinimizeBox = False
    7.         Me.MaximizeBox = False
    8.         Me.Text = ""
    9.         Me.ShowInTaskbar = False
    10.         proxyForm.Text = "MyText"
    11.         proxyForm.Opacity = 0 'make ProxyFrom invisible.
    12.         proxyForm.Show(Me) 'make ProxyForm Owned
    13.     End Sub
    14. End Class
    I tried it in XP, but I've no idea how it will look in other OS versions. Something would have to be done about the extra icon in Alt-Tab, but I believe there are ways of dealing with that.

    regards, BB
    Last edited by boops boops; Apr 16th, 2010 at 03:18 PM.

  14. #14
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Quote Originally Posted by NickThissen View Post
    I'm starting to freak out slightly now ... That code gives me no border at all, like what you described with my code... Did MS really change this behavior completely in Win7??
    Why not just Check the OS Version, and If it's vista plus, Set it to your code, and if It's not, then set it to my code.

  15. #15

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Well if you think about it, it shouldn't be that far-fetched that it was changed so drastically. Aero is completely different than the default theme in Windows XP and I wouldn't be surprised if something had changed. In fact, I'd be a bit concerned if something didn't change. After all, wasn't Vista/7 a rewrite of Windows?

  16. #16
    New Member Hags61's Avatar
    Join Date
    Sep 2008
    Posts
    3

    Re: Form without titlebar, but with title text (to show in taskbar)?

    Just happened to take a glance and your boarder still shows on XP Pro machines. I would not expect it to be any different on XP Home or other.

    Code:
    Imports System.Windows.Forms
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Text = "My Caption"
            Me.Location = New Drawing.Point(500, 500)
        End Sub
    
        Protected Overrides ReadOnly Property CreateParams() As CreateParams
            Get
                Dim cp As CreateParams = MyBase.CreateParams
                cp.Style = cp.Style And Not &HC00000 ' WS_CAPTION
                Return cp
            End Get
        End Property
    End Class
    This produces: http://picasaweb.google.com/lh/photo...eat=directlink
    Last edited by Hags61; Feb 2nd, 2011 at 05:56 PM. Reason: Image not showing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width