想用VB实现一个功能,将一个窗口移动到指定位置 并拉伸高度和宽度 类似鼠标拉伸窗口
3个回答
2011-05-06
展开全部
'画两个按钮,使用如下代码
Option Explicit
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "限制"
Command2.Caption = "解除"
End Sub
Private Sub Command1_Click()
Dim client As RECT
Dim upperleft As POINT
Dim hWnd As Long
'查找标题为“form1”的窗口
hWnd = FindWindow(vbNullString, "Form1")
GetClientRect hWnd, client
upperleft.x = client.left
upperleft.y = client.top
ClientToScreen hWnd, upperleft
OffsetRect client, upperleft.x, upperleft.y
ClipCursor client
End Sub
Private Sub Command2_Click()
ClipCursor ByVal 0&
End Sub
Private Sub Form_Unload(Cancel As Integer)
ClipCursor ByVal 0&
End Sub
另外,团IDC网上有许多产品团购,便宜有口碑
Option Explicit
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "限制"
Command2.Caption = "解除"
End Sub
Private Sub Command1_Click()
Dim client As RECT
Dim upperleft As POINT
Dim hWnd As Long
'查找标题为“form1”的窗口
hWnd = FindWindow(vbNullString, "Form1")
GetClientRect hWnd, client
upperleft.x = client.left
upperleft.y = client.top
ClientToScreen hWnd, upperleft
OffsetRect client, upperleft.x, upperleft.y
ClipCursor client
End Sub
Private Sub Command2_Click()
ClipCursor ByVal 0&
End Sub
Private Sub Form_Unload(Cancel As Integer)
ClipCursor ByVal 0&
End Sub
另外,团IDC网上有许多产品团购,便宜有口碑
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SetWIndowPos API函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用form1.move语句可以实现。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询