vb 移动窗口
我想把form5移动到form3中picture1的位置,下面是我的代码(在form3的code中):Dimr2AsRECTGetWindowRectPicture1.h...
我想把form5移动到form3中picture1的位置,下面是我的代码(在form3的code中):
Dim r2 As RECT
GetWindowRect Picture1.hwnd, r2
Form5.ScaleMode = vbPixels '设置坐标单位为像素
Form5.Move r2.Left, r2.Top
Form5.Show
为什么移动的坐标仍然是默认的缇而不是屏幕像素呢?
请指教!
要实现窗口的正确移动,应该怎么做? 展开
Dim r2 As RECT
GetWindowRect Picture1.hwnd, r2
Form5.ScaleMode = vbPixels '设置坐标单位为像素
Form5.Move r2.Left, r2.Top
Form5.Show
为什么移动的坐标仍然是默认的缇而不是屏幕像素呢?
请指教!
要实现窗口的正确移动,应该怎么做? 展开
展开全部
将form5的左上角的位置挪到form3中picture1左上角的位置
'form3中
Private Type rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Command1_Click()
Dim wrect As rect
Dim picrect As rect
GetWindowRect Picture1.hwnd, picrect
GetWindowRect Form5.hwnd, wrect
MoveWindow Form5.hwnd, picrect.Left, picrect.Top, wrect.Right - wrect.Left, wrect.Bottom - wrect.Top, True
Form5.Show
End Sub
'form3中
Private Type rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Command1_Click()
Dim wrect As rect
Dim picrect As rect
GetWindowRect Picture1.hwnd, picrect
GetWindowRect Form5.hwnd, wrect
MoveWindow Form5.hwnd, picrect.Left, picrect.Top, wrect.Right - wrect.Left, wrect.Bottom - wrect.Top, True
Form5.Show
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询