Results 1 to 8 of 8

Thread: How to remove the title bar from a EXE

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Strasbourg
    Posts
    30

    How to remove the title bar from a EXE

    Hello,

    I would like to know how I could remove the title bar from an application executed from VB in a standalone window.

    I need to keep the possibility to move and resize the window.
    For information, the EXE window is a child window from the MDI of my VB project.

    Thank in advance for your help.

    she

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    This is a function I use for removing titlebar's from windows, not sure how you would go about letting it be moved:

    VB Code:
    1. Public Function SetBorder(ByVal hWnd As Long, ByVal Visible As Boolean) As Boolean
    2.     Dim lngStyle As Long
    3.     'Get the current style
    4.     lngStyle = GetWindowLong(hWnd, GWL_STYLE)
    5.     'If we want the caption visible
    6.     If Visible Then
    7.         lngStyle = lngStyle Or WS_CAPTION
    8.     'If we don't
    9.     Else
    10.         lngStyle = lngStyle And Not WS_CAPTION
    11.     End If
    12.     'Set the new style
    13.     Call SetWindowLong(hWnd, GWL_STYLE, 0 Or lngStyle)
    14.     'Show the changes
    15.     Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or _
    16.         SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE)
    17.     'Return True if successful, false if not
    18.     SetBorder = (lngStyle = GetWindowLong(hWnd, GWL_STYLE))
    19. End Function

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    See this link
    for moving borderless form

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Someone posted this here a while back and it seems to work pretty well.
    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 Command1_Click()
    23.     Unload Me
    24. End Sub
    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. End Sub
    30.  
    31. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    32.     'Move the form with the Left Mouse Button
    33.     If Button = vbLeftButton Then
    34.         Me.MousePointer = vbSizeAll
    35.         Call ReleaseCapture
    36.         Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    37.         Me.MousePointer = vbArrow
    38.     End If
    39. End Sub

  5. #5
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    If u r making exe in VB then during deign time set the Forms BorderStyle property to None.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Strasbourg
    Posts
    30
    Originally posted by MarkT
    Someone posted this here a while back and it seems to work pretty well.
    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 Command1_Click()
    23.     Unload Me
    24. End Sub
    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. End Sub
    30.  
    31. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    32.     'Move the form with the Left Mouse Button
    33.     If Button = vbLeftButton Then
    34.         Me.MousePointer = vbSizeAll
    35.         Call ReleaseCapture
    36.         Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    37.         Me.MousePointer = vbArrow
    38.     End If
    39. End Sub

    I've already tested this code in my application, it did not work very good.
    I think the problem might be that the external application is not a VB compiled EXE.

    she

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Strasbourg
    Posts
    30
    Originally posted by she
    I've already tested this code in my application, it did not work very good.
    I think the problem might be that the external application is not a VB compiled EXE.

    she
    My external application is unfortunately not a VB program and I can't modify anything in it.

    she

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Strasbourg
    Posts
    30
    Originally posted by Rick Bull
    This is a function I use for removing titlebar's from windows, not sure how you would go about letting it be moved:

    VB Code:
    1. Public Function SetBorder(ByVal hWnd As Long, ByVal Visible As Boolean) As Boolean
    2.     Dim lngStyle As Long
    3.     'Get the current style
    4.     lngStyle = GetWindowLong(hWnd, GWL_STYLE)
    5.     'If we want the caption visible
    6.     If Visible Then
    7.         lngStyle = lngStyle Or WS_CAPTION
    8.     'If we don't
    9.     Else
    10.         lngStyle = lngStyle And Not WS_CAPTION
    11.     End If
    12.     'Set the new style
    13.     Call SetWindowLong(hWnd, GWL_STYLE, 0 Or lngStyle)
    14.     'Show the changes
    15.     Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or _
    16.         SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE)
    17.     'Return True if successful, false if not
    18.     SetBorder = (lngStyle = GetWindowLong(hWnd, GWL_STYLE))
    19. End Function

    Hi,

    To respond to your question, I would say that my main program is a VB MDI. That MDI includes a window with an external program not designed and compiled with VB. So it is impossible for me to change anything in it. I need the possibility to move and resize the application in my own program, this means in my MDI form.
    Thank you for your code. I will try it right now.

    she

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