Results 1 to 26 of 26

Thread: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Resolved [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    How can I make a form have no Titlebar, be resizeable, and have a caption in the taskbar?

  2. #2
    Lively Member
    Join Date
    Jul 2006
    Posts
    119

    Re: Form with no Titlebar but with Caption in Taskbar

    Can I ask one thing, You do not know that.
    Thats the 1st thing I ever did learn lol. An it was easy as pie.
    Here. Use google...
    Search, Make a boarderless window that can resize
    An the title bar tect is done from the title caption on the properties. It will do the same on the taskbar...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Form with no Titlebar but with Caption in Taskbar

    But I also want to be able to resize the window from the sides as well.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Form with no Titlebar but with Caption in Taskbar

    And I was just wondering if theres a simple way to do this without having to use all of those custom controls.

  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Form with no Titlebar but with Caption in Taskbar

    Here is some code I've had laying around a while. I think it is what you are after. For the form style property select 2-Sizeable.
    VB Code:
    1. Option Explicit
    2.  
    3. 'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
    4. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    5.                             (ByVal hwnd As Long, ByVal nIndex As Long, _
    6.                             ByVal dwNewLong As Long) As Long
    7. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    8.                             (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    9.                            
    10. Private Const GWL_STYLE = (-16)
    11. Private Const WS_DLGFRAME = &H400000
    12.  
    13. 'API Calls Used To Move A Form With The Mouse
    14. Private Declare Function ReleaseCapture Lib "user32" () As Long
    15. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    16.                             (ByVal hwnd As Long, ByVal wMsg As Long, _
    17.                             ByVal wParam As Long, lParam As Any) As Long
    18.  
    19. Private Const HTCAPTION = 2
    20. Private Const WM_NCLBUTTONDOWN = &HA1
    21.  
    22. Private Sub Form_Load()
    23.     'ERASE the Title Bar
    24.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    25. End Sub
    26.  
    27. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    28.     'Move the form with the Left Mouse Button
    29.     If Button = vbLeftButton Then
    30.         Me.MousePointer = vbSizeAll
    31.         Call ReleaseCapture
    32.         Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    33.         Me.MousePointer = vbArrow
    34.     End If
    35. End Sub

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Form with no Titlebar but with Caption in Taskbar

    Whoa! Thanks! That was exactly what I was looking for. I think I posted a topic similar to this before but I can't find it.

  7. #7
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    is there a way of "deactivating" or returning the form back to normal? i put the code in a "fullscreen" menu button thing.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    Yeah, and also the titlebar reappears after I change the form's caption. How do I avoid that?

  9. #9
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    anyone............???

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    I guess not

  11. #11
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    dang... wheres MarkT?? WHY HAS HE FORESAKEN US?!!! *runs to a corner and cries*

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    Probably when you change the caption it removes the style and shows the title bar again. So I would assume that your could just make another call of the line that removes it.

    VB Code:
    1. SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    You need to change the style back to its original state before making you changes and then remove the title bar again.
    VB Code:
    1. Private Sub Command1_Click()
    2.     'Set the style back to where you started
    3.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) - WS_DLGFRAME
    4.     'Change your caption
    5.     Me.Caption = "New Caption"
    6.     'Remove the title bar
    7.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    8. End Sub

  14. #14
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    Quote Originally Posted by battery
    is there a way of "deactivating" or returning the form back to normal? i put the code in a "fullscreen" menu button thing.
    Menu options or command buttons

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    Thanks!

  16. #16
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    i stuck in in a menu option and im trying to adapt it into my project

  17. #17
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    arg it fails - heres my code... please make it work :P

    VB Code:
    1. Private Sub mnuflashfs_Click()
    2. Dim t As Integer, l As Integer, w As Integer, h As Integer
    3. fs = False
    4. If fs = False Then
    5.   If mnuflashfs.Caption = "Fullscreen" Then
    6.     t = Top
    7.     l = Left
    8.     w = Width
    9.     h = Height
    10.     Top = 0
    11.     Left = 0
    12.     frmflash.Height = Screen.Height + 450
    13.     frmflash.Width = Screen.Width
    14.     flashplayer.Height = Screen.Height
    15.     flashplayer.Width = Screen.Width
    16.     mnuflashfs.Caption = "Normal"
    17.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    18.     fs = True
    19.   End If
    20. End If
    21.  
    22. If fs = False Then
    23.   If mnuflashfs.Caption = "Normal" Then
    24.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) - WS_DLGFRAME
    25.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    26.     Top = t
    27.     Left = l
    28.     Width = w
    29.     Height = h
    30.     flashplayer.Height = Height
    31.     flashplayer.Width = Width
    32.     mnuflashfs.Caption = "Fullscreen"
    33.     fs = True
    34.   End If
    35. End If
    36. fs = False
    37. End Sub

    i dont know why it doesnt wanna work

    i made a buncha variables (t,l,w,h) as the settings prior to the fullscreening, so when they de-fullscreen it , the form goes back to the prior size.. plz help

  18. #18
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    its been 5 days.. does no one have an answer to my inquiry?????

  19. #19
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    If you want the title bar back then just update the formcaption

  20. #20
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    doesnt work

    i did all that stuff and it doesnt wanna work
    i added in the caption thing and still nothing

  21. #21
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    it says a form cant be maximized/minimized bla bla bla - if i take out the t,l,w,h it doesnt do anything but change the caption of the menu

  22. #22
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    If all you are trying to do is change between fulls creen and normal form size then just change the windowstate property.
    VB Code:
    1. Option Explicit
    2.  
    3. 'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
    4. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    5.                             (ByVal hwnd As Long, ByVal nIndex As Long, _
    6.                             ByVal dwNewLong As Long) As Long
    7. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    8.                             (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    9.                            
    10. Private Const GWL_STYLE = (-16)
    11. Private Const WS_DLGFRAME = &H400000
    12.  
    13. 'API Calls Used To Move A Form With The Mouse
    14. Private Declare Function ReleaseCapture Lib "user32" () As Long
    15. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    16.                             (ByVal hwnd As Long, ByVal wMsg As Long, _
    17.                             ByVal wParam As Long, lParam As Any) As Long
    18.  
    19. Private Const HTCAPTION = 2
    20. Private Const WM_NCLBUTTONDOWN = &HA1
    21.  
    22. Dim t As Integer, l As Integer, w As Integer, h As Integer
    23. Dim fs As Boolean
    24.  
    25.  
    26. Private Sub Form_Load()
    27.     'ERASE the Title Bar
    28.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    29.    
    30.     mnuflashfs.Caption = "Fullscreen"
    31. End Sub
    32.  
    33. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    34.     'Move the form with the Left Mouse Button
    35.     If Button = vbLeftButton Then
    36.         Me.MousePointer = vbSizeAll
    37.         Call ReleaseCapture
    38.         Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    39.         Me.MousePointer = vbArrow
    40.     End If
    41. End Sub
    42.  
    43.  
    44. Private Sub mnuflashfs_Click()
    45.     If mnuflashfs.Caption = "Fullscreen" Then
    46.         Me.WindowState = vbMaximized
    47.         mnuflashfs.Caption = "Normal"
    48.     Else
    49.         Me.WindowState = vbNormal
    50.         mnuflashfs.Caption = "Fullscreen"
    51.     End If
    52. End Sub

  23. #23
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    it sorta works, cept that when the form loads it starts without the title bar (borderstyle 0 or whatever) - i'd like for it to start with the border, then when the user clicks the fs menu thing then it ditches the border - when the click it again, to make the form normal, it add back the border thing

  24. #24
    Addicted Member battery's Avatar
    Join Date
    Oct 2006
    Posts
    169

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    heres what i've adapted:
    VB Code:
    1. Private Sub mnuflashfs_Click()
    2.   ' all of this is pretty obvious but i'll explain anyway...
    3.   If mnuflashfs.Caption = "Fullscreen" Then
    4.     'store the top,left,width, and heigh prior to fullscreening
    5.     t = Top
    6.     l = Left
    7.     w = Width
    8.     h = Height
    9.     'set the top and left to the top left corner of the screen - didnt do that before
    10.     Me.Top = 0
    11.     Me.Left = 0
    12.     flashplayer.Height = Screen.Height
    13.     flashplayer.Width = Screen.Width
    14.     'and heres your stuff
    15.     Me.WindowState = vbMaximized
    16.     SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    17.     mnuflashfs.Caption = "Normal"
    18.   Else
    19.     'reapply prior settings
    20.     Width = w
    21.     Height = h
    22.     Top = t
    23.     Left = l
    24.     'your stuff once more
    25.     Me.WindowState = vbNormal
    26.     mnuflashfs.Caption = "Fullscreen"
    27.     End If
    28. End Sub

    my code doesnt work - when it's fullscreened when you click it just makes a beep sound when you click (like when you have a popup and when you click off it - that sound)

  25. #25

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    I got notepad's current hWnd (with Spy++) and got rid of its menu bar
    Attached Images Attached Images  
    Last edited by Doomguy0505; Nov 2nd, 2006 at 07:14 AM.

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar

    I've run into a slight problem with the code. When I maximize the window, the window fills up the entire screen, including the taskbar (I have the taskbar set to stay on top of other windows and the test window isn't set to stay on top of other windows). Is there a way for the window to stop at the taskbar? Thanks

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