Results 1 to 11 of 11

Thread: [RESOLVED] Remove Title Bar Off Of Form Using API's

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Resolved [RESOLVED] Remove Title Bar Off Of Form Using API's

    I just want to remove the titlebar of a form using API's, yet still be able to keep the black boarder around the form. Setting the Borderstyle to 0 - None removes both, and I don't want that. Any ideas on how I can pull this off?

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Remove Title Bar Off Of Form Using API's

    Set the form border style to 1 - Fixed Single then remove the form caption and set the form Control Box to False.

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Remove Title Bar Off Of Form Using API's

    This code works, the only problem is it change the border color, in my case is becomes gray, when it should be blue.
    'IN A MODULE
    VB Code:
    1. 'Remove Title Bar
    2. Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    3. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    4. Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    5. Private Const GWL_STYLE = (-16)
    6. Private Const WS_CAPTION = &HC00000
    7. Private Const SWP_FRAMECHANGED = &H20
    8. Private Const SWP_NOMOVE = &H2
    9. Private Const SWP_NOZORDER = &H4
    10. Private Const SWP_NOSIZE = &H1
    11.  
    12. Public Sub Form_RemoveTitleBar(f As Form, ShowTitle As Boolean)
    13. Dim Style As Long
    14.     ' Get window's current style bits.
    15.     Style = GetWindowLong(f.hwnd, GWL_STYLE)
    16.     ' Set the style bit for the title on or off.
    17.     If ShowTitle Then
    18.         Style = Style Or WS_CAPTION
    19.     Else
    20.         Style = Style And Not WS_CAPTION
    21.     End If
    22.     ' Send the new style to the window.
    23.     SetWindowLong f.hwnd, GWL_STYLE, Style
    24.     ' Repaint the window.
    25.     SetWindowPos f.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
    26. End Sub

    FORM:
    VB Code:
    1. Private Sub Form_Load()
    2.     Form_RemoveTitleBar Me, True     'Remove
    3.     Form_RemoveTitleBar Me, False    'Return
    4. End Sub

  4. #4

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Remove Title Bar Off Of Form Using API's

    To jcis: Crap, it still removed the border. And you may wanna fix your code cause False removed it, and True made it stay.

    To Lintz: I'm cannot do that like I said cause I'm just wanting to remove the titlebar, not the border and titlebar. The border must stay somehow.

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Remove Title Bar Off Of Form Using API's

    It doesn't remove the border, you can see the Form is still resizable, it removes the controlbox, the controlbox is not only the titlebar, its also that colored line that houses the Form.

  6. #6
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Remove Title Bar Off Of Form Using API's

    The black border is still visible using my code.....

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Remove Title Bar Off Of Form Using API's

    Jr, add a menu and make it's visibility false. Then take the caption and the control box away

  8. #8
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Remove Title Bar Off Of Form Using API's

    |2eM!x, that's what I originally posted (without the invisible menu)

  9. #9

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Remove Title Bar Off Of Form Using API's

    Quote Originally Posted by lintz
    The black border is still visible using my code.....
    Ohhhhh, I didn't remove the caption. Duh.

    Ahhhh nutz, it's only a 2D border and not a 3D one. I guess my only solution is to draw the borders by hand using the Line() statement.

  10. #10
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Remove Title Bar Off Of Form Using API's

    Nope, if you want it 3d, set BorderStyle = 2 (3d border and sizable)

  11. #11

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Remove Title Bar Off Of Form Using API's

    Sweet!!! Thanks man.

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