|
-
Sep 20th, 2002, 07:20 AM
#1
Thread Starter
Junior Member
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
-
Sep 20th, 2002, 08:57 AM
#2
Frenzied Member
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:
Public Function SetBorder(ByVal hWnd As Long, ByVal Visible As Boolean) As Boolean
Dim lngStyle As Long
'Get the current style
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
'If we want the caption visible
If Visible Then
lngStyle = lngStyle Or WS_CAPTION
'If we don't
Else
lngStyle = lngStyle And Not WS_CAPTION
End If
'Set the new style
Call SetWindowLong(hWnd, GWL_STYLE, 0 Or lngStyle)
'Show the changes
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE)
'Return True if successful, false if not
SetBorder = (lngStyle = GetWindowLong(hWnd, GWL_STYLE))
End Function
-
Sep 20th, 2002, 09:14 AM
#3
PowerPoster
See this link
for moving borderless form
-
Sep 20th, 2002, 11:54 AM
#4
Someone posted this here a while back and it seems to work pretty well.
VB Code:
Option Explicit
'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_DLGFRAME = &H400000
'API Calls Used To Move A Form With The Mouse
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
'ERASE the Title Bar
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Move the form with the Left Mouse Button
If Button = vbLeftButton Then
Me.MousePointer = vbSizeAll
Call ReleaseCapture
Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
Me.MousePointer = vbArrow
End If
End Sub
-
Sep 20th, 2002, 12:44 PM
#5
Fanatic Member
If u r making exe in VB then during deign time set the Forms BorderStyle property to None.
-
Sep 23rd, 2002, 06:55 AM
#6
Thread Starter
Junior Member
Originally posted by MarkT
Someone posted this here a while back and it seems to work pretty well.
VB Code:
Option Explicit
'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_DLGFRAME = &H400000
'API Calls Used To Move A Form With The Mouse
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
'ERASE the Title Bar
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Move the form with the Left Mouse Button
If Button = vbLeftButton Then
Me.MousePointer = vbSizeAll
Call ReleaseCapture
Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
Me.MousePointer = vbArrow
End If
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
-
Sep 23rd, 2002, 06:56 AM
#7
Thread Starter
Junior Member
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
-
Sep 23rd, 2002, 06:59 AM
#8
Thread Starter
Junior Member
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:
Public Function SetBorder(ByVal hWnd As Long, ByVal Visible As Boolean) As Boolean
Dim lngStyle As Long
'Get the current style
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
'If we want the caption visible
If Visible Then
lngStyle = lngStyle Or WS_CAPTION
'If we don't
Else
lngStyle = lngStyle And Not WS_CAPTION
End If
'Set the new style
Call SetWindowLong(hWnd, GWL_STYLE, 0 Or lngStyle)
'Show the changes
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE)
'Return True if successful, false if not
SetBorder = (lngStyle = GetWindowLong(hWnd, GWL_STYLE))
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|