那个窗体中是不是有菜单项存在,如果存在菜单,无法通过设置boardstyle隐藏标题栏。
隐藏请参考以下代码:
窗体声明的API函数及其常数:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const WS_SIZEBOX = &H40000
Private Const WS_BORDER = &H800000
Private Const GWL_STYLE = (-16)
在窗体加载事件中添加以下代码
Dim hMenu As Long
hMenu = GetWindowLong(Me.hWnd, GWL_STYLE)
hMenu = hMenu And Not WS_BORDER And Not WS_SIZEBOX '隐藏标题栏
SetWindowLong Me.hWnd, GWL_STYLE, hMenu '将style赋予窗体