VB中如何禁止拖动窗口边缘改变大小?
展开全部
给你个参考代码琢磨琢磨就知道了
Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOSIZE = &H1
Sub main()
Dim hwnd As Long
Dim lStyle As Long
hwnd = FindWindow(vbNullString, "计算器")
If hwnd <> 0 Then
'获得窗口样式
lStyle = GetWindowLong(hwnd, GWL_STYLE)
'取消窗口样式中的最大化和最小化按钮
SetWindowLong hwnd, GWL_STYLE, lStyle And Not WS_MAXIMIZEBOX And Not WS_MINIMIZEBOX
'使样式立即生效
SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End If
End Sub
Private Sub Command1_Click()
Call main
End Sub
Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOSIZE = &H1
Sub main()
Dim hwnd As Long
Dim lStyle As Long
hwnd = FindWindow(vbNullString, "计算器")
If hwnd <> 0 Then
'获得窗口样式
lStyle = GetWindowLong(hwnd, GWL_STYLE)
'取消窗口样式中的最大化和最小化按钮
SetWindowLong hwnd, GWL_STYLE, lStyle And Not WS_MAXIMIZEBOX And Not WS_MINIMIZEBOX
'使样式立即生效
SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End If
End Sub
Private Sub Command1_Click()
Call main
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以设置form的Borderstyle的值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询