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
Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
Private Sub Form_Load()
Dim L As Long
L = GetWindowLong(Me.hWnd, GWL_STYLE)
L = L And Not (WS_CAPTION)
L = SetWindowLong(Me.hWnd, GWL_STYLE, L)
Me.Move Me.Left, Me.Top, Me.Width, Me.Height - 10
End Sub
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
Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
Private Sub Form_Load()
Dim L As Long
L = GetWindowLong(Me.hWnd, GWL_STYLE)
L = L And Not (WS_CAPTION)
L = SetWindowLong(Me.hWnd, GWL_STYLE, L)
Me.Move Me.Left, Me.Top, Me.Width, Me.Height - 10
End Sub
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_SYSMENU = &H80000
Private Const WS_CAPTION = &HC00000
Private Const WS_SIZEBOX = &H40000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
'为窗体指定一个新位置和状态函数
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 Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOREPOSITION = &H200
'获得整个窗体的大小和位置
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim lStyle As Long
Dim MyRect As RECT
Dim Change As Boolean
'获取窗体的大小和位置
GetWindowRect Me.hwnd, MyRect
'取得当前窗体信息
lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_CAPTION
lStyle = lStyle And Not WS_SIZEBOX
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
'按lStyle的值设置窗体信息
SetWindowLong Me.hwnd, GWL_STYLE, lStyle
'保持窗体的大小与位置不变
SetWindowPos Me.hwnd, 0, MyRect.Left, MyRect.Top, MyRect.Right - MyRect.Left, MyRect.Bottom - MyRect.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED