设计的时候不要把窗体设置为无边框的,而是用代码改成无边框样式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 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 Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Const WS_SYSMENU = &H80000 Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_CAPTION = &HC00000 Private Const WS_THICKFRAME = &H40000 Private Const GWL_STYLE As Long = (-16) Private Const SWP_NOMOVE As Long = &H2 Private Const SWP_NOSIZE As Long = &H1 Private Const SWP_NOZORDER As Long = &H4 Private Const SWP_FRAMECHANGED = &H20 Private Const SWP_NOOWNERZORDER = &H200 Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDERPrivate Sub TitleBarVisible(hWnd As Long, Value As Boolean) Dim Style As Long Style = GetWindowLong(hWnd, GWL_STYLE) If Value Then Style = Style Or WS_SYSMENU Style = Style Or WS_MAXIMIZEBOX Style = Style Or WS_MINIMIZEBOX Style = Style Or WS_CAPTION Style = Style Or WS_THICKFRAME Else Style = Style And Not WS_MAXIMIZEBOX Style = Style And Not WS_CAPTION Style = Style And Not WS_THICKFRAME
End If SetWindowLong hWnd, GWL_STYLE, Style SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED End SubPrivate Sub Form_Load() TitleBarVisible Me.hWnd, False End Sub
Private 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
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const WS_SYSMENU = &H80000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_CAPTION = &HC00000
Private Const WS_THICKFRAME = &H40000
Private Const GWL_STYLE As Long = (-16)
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDERPrivate Sub TitleBarVisible(hWnd As Long, Value As Boolean)
Dim Style As Long
Style = GetWindowLong(hWnd, GWL_STYLE)
If Value Then
Style = Style Or WS_SYSMENU
Style = Style Or WS_MAXIMIZEBOX
Style = Style Or WS_MINIMIZEBOX
Style = Style Or WS_CAPTION
Style = Style Or WS_THICKFRAME
Else
Style = Style And Not WS_MAXIMIZEBOX
Style = Style And Not WS_CAPTION
Style = Style And Not WS_THICKFRAME
End If
SetWindowLong hWnd, GWL_STYLE, Style
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
End SubPrivate Sub Form_Load()
TitleBarVisible Me.hWnd, False
End Sub
设计时候把窗口改为无边框
然后 SetWindowLong 一下就好,我很久以前用过~
现在把一个参数忘掉了,正在找,头疼ing...