在Form_Load里面写入代码 ShowTitleBar Me.hWnd, False添加一个模块,写入内容 Option Explicit Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long 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 Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As LongPublic Const GWL_STYLE = (-16) Public Const WS_CAPTION = &HC00000 'WS_BORDER 或 WS_DLGFRAME Public Const WS_MAXIMIZEBOX = &H10000 Public Const WS_MINIMIZEBOX = &H20000 Public Const WS_SYSMENU = &H80000Public Enum ESetWindowPosStyles SWP_SHOWWINDOW = &H40 SWP_HIDEWINDOW = &H80 SWP_FRAMECHANGED = &H20 'The frame changed: send WM_NCCALCSIZE SWP_NOACTIVATE = &H10 SWP_NOCOPYBITS = &H100 SWP_NOMOVE = &H2 SWP_NOOWNERZORDER = &H200 'Dont do owner Z ordering SWP_NOREDRAW = &H8 SWP_NOREPOSITION = SWP_NOOWNERZORDER SWP_NOSIZE = &H1 SWP_NOZORDER = &H4 SWP_DRAWFRAME = SWP_FRAMECHANGED HWND_NOTOPMOST = -2 End EnumPublic Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePublic Function ShowTitleBar(hWnd As Long, ByVal bState As Boolean) Dim lStyle As Long Dim tR As RECT GetWindowRect hWnd, tR lStyle = GetWindowLong(hWnd, GWL_STYLE) If bState Then lStyle = lStyle Or WS_CAPTION Else lStyle = lStyle And Not WS_CAPTION End If SetWindowLong hWnd, GWL_STYLE, lStyle SetWindowPos hWnd, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom - tR.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED 'SetWindowText Me.hwnd, Caption End Function
ShowTitleBar Me.hWnd, False添加一个模块,写入内容
Option Explicit
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
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
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As LongPublic Const GWL_STYLE = (-16)
Public Const WS_CAPTION = &HC00000 'WS_BORDER 或 WS_DLGFRAME
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_SYSMENU = &H80000Public Enum ESetWindowPosStyles
SWP_SHOWWINDOW = &H40
SWP_HIDEWINDOW = &H80
SWP_FRAMECHANGED = &H20 'The frame changed: send WM_NCCALCSIZE
SWP_NOACTIVATE = &H10
SWP_NOCOPYBITS = &H100
SWP_NOMOVE = &H2
SWP_NOOWNERZORDER = &H200 'Dont do owner Z ordering
SWP_NOREDRAW = &H8
SWP_NOREPOSITION = SWP_NOOWNERZORDER
SWP_NOSIZE = &H1
SWP_NOZORDER = &H4
SWP_DRAWFRAME = SWP_FRAMECHANGED
HWND_NOTOPMOST = -2
End EnumPublic Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePublic Function ShowTitleBar(hWnd As Long, ByVal bState As Boolean)
Dim lStyle As Long
Dim tR As RECT
GetWindowRect hWnd, tR
lStyle = GetWindowLong(hWnd, GWL_STYLE)
If bState Then
lStyle = lStyle Or WS_CAPTION
Else
lStyle = lStyle And Not WS_CAPTION
End If
SetWindowLong hWnd, GWL_STYLE, lStyle SetWindowPos hWnd, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom - tR.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
'SetWindowText Me.hwnd, Caption
End Function