| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 666 人关注过本帖
标题:怎么实现按下窗体移动鼠标即可移动窗体位置
只看楼主 加入收藏
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
结帖率:100%
收藏
 问题点数:0 回复次数:6 
怎么实现按下窗体移动鼠标即可移动窗体位置
如题
搜索更多相关主题的帖子: 鼠标 窗体 位置 
2007-04-23 20:03
西山居士
Rank: 4
等 级:贵宾
威 望:11
帖 子:581
专家分:0
注 册:2007-4-21
收藏
得分:0 


b13690976754

来自:207寝室
等级:小飞侠
文章:1028
积分:8380
注册:2006年11月9日
-------------------------
这样的问题……


2007-04-23 20:33
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
请会的朋友指点题目好吗?

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-23 20:38
Joforn
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1242
专家分:122
注 册:2007-1-2
收藏
得分:0 

'实例二(窗体鼠标左键拖动时移动窗体)
'主要用于无边框窗体移动,当然也可以移动有边框的窗体。

'******************************************************************************************************************
'*********** 作 者 :南宫飘雪
'*********** Email :joforn@sohu.com
'*********** QQ号码:42978116
'*********** Blog :http://blog.163.com/joforn/
'******************************************************************************************************************
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
theForm_Move Button
End Sub

Private Sub theForm_Move(ByVal Button As Integer)
If Button <> vbLeftButton Then Exit Sub
ReleaseCapture
SendMessage hwnd, &HA1, 2, 0
mouse_event &H4, 0, 0, 0, 0 '这条不用,但在某些特殊情况下就要用了(我自己写的程序里不用就会出错。呵)。
End Sub

'这是我的API函数查询管理器中的实例

[此贴子已经被作者于2007-4-23 20:56:54编辑过]


VB QQ群:47715789
2007-04-23 20:42
西山居士
Rank: 4
等 级:贵宾
威 望:11
帖 子:581
专家分:0
注 册:2007-4-21
收藏
得分:0 

唉``给你写个简单的吧
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub


2007-04-23 20:44
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
谢谢

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-23 20:46
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 

Dim mouseX, mouseY, currX, currY As Single
Dim flag As Boolean
Private Sub Form_Load()
flag = False
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mouseX = X
mouseY = Y
flag = True

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbKeyLButton And flag = True Then
currX = Me.Left - mouseX + X
currY = Me.Top - mouseY + Y
Me.Move currX, currY
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
flag = False
End Sub



/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-23 21:08
快速回复:怎么实现按下窗体移动鼠标即可移动窗体位置
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052908 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved