如何隐藏标题栏
各位大侠,我刚接触vb6,想把标题栏隐藏,将borderstyle设置为0-None后,加了一个菜单运行后,标题栏有出来了,请问怎么解决?
Public Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
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 GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As Rect) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_CAPTION = &HC00000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_SYSMENU = &H80000
Public Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Const LWA_ALPHA = &H2
Public Const LWA_COLORKEY = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const flags = SWP_NOMOVE Or SWP_NOSIZE
Public Function ShowTitleBar(Frm As Form, ByVal bState As Boolean, Optional H As Long, Optional W As Long) '去除窗体标题栏
Dim lStyle As Long
Dim tR As Rect
GetWindowRect Frm.hWnd, tR
lStyle = GetWindowLong(Frm.hWnd, GWL_STYLE)
If (bState) Then
' Frm.Caption = Frm.Tag
If Frm.ControlBox Then
lStyle = lStyle Or WS_SYSMENU
End If
If Frm.MaxButton Then
lStyle = lStyle Or WS_MAXIMIZEBOX
End If
If Frm.MinButton Then
lStyle = lStyle Or WS_MINIMIZEBOX
End If
If Frm.Caption <> "" Then
lStyle = lStyle Or WS_CAPTION
End If
Else
'Frm.Tag = Frm.Caption
'Frm.Caption = ""
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
lStyle = lStyle And Not WS_CAPTION
End If
SetWindowLong Frm.hWnd, GWL_STYLE, lStyle
Frm.Height = H
Frm.Width = W
End Function