请教关于mouse_down,mouse_up,和mouse_move 的应用

sekfore 2001-07-27 12:46:25
我在做一个程序,想用鼠标可以拖动form。可是由于mouse_move是不断产生的。导致form不断的“颤抖”。请大家帮忙解决啊,谢谢了! :)
...全文
241 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sekfore 2001-07-29
  • 打赏
  • 举报
回复
我知道了。是层叠事件
xxlroad 2001-07-28
  • 打赏
  • 举报
回复
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_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0
End Sub
tg123 2001-07-28
  • 打赏
  • 举报
回复
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 Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2

Private Sub Form1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture

SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0

End Sub
DevilXelloss 2001-07-27
  • 打赏
  • 举报
回复
在 Form_MouseDown() 里面:
ReleaseCapture
SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
DevilXelloss 2001-07-27
  • 打赏
  • 举报
回复
你要拖动 Form,只需在 Form_MouseDown() 用 SendMessage 向 Form 发送 WM_NCLBUTTONDOWN 消息就可以了,把 HitTest 设置为 Caption,就会模拟出拖动窗体标题栏的效果。
songyangk 2001-07-27
  • 打赏
  • 举报
回复
据我所知,在VB里用这种方法调用,就是抖呀!
herony 2001-07-27
  • 打赏
  • 举报
回复
应该只识别MouseMove吧,如果 Down也识别,是不颤抖了,可是却跳了,我感觉还是在move时可以调用一个延时的程序,比如50ms,这样就不会颤抖了,具体使用Sleep API函数
Amoon 2001-07-27
  • 打赏
  • 举报
回复
hehe,很老的办法嘛。
sekfore 2001-07-27
  • 打赏
  • 举报
回复
谢谢!
sssoft 2001-07-27
  • 打赏
  • 举报
回复
Dim ox&, oy&, sx&, sy&

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
sx = X
sy = Y
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then

With Me
.Move .Left + (X - sx), .Top + (Y - sy)
ox = .Left
oy = .Top
End With
End If

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Move ox, oy
End Sub
gameboy999 2001-07-27
  • 打赏
  • 举报
回复
to DevilXelloss:
模拟发送这种消息有个很大的弱点,就是如果窗体比较大的话,则往上拖动会拖不上去~~
因为它是模拟Caption拖动的消息,而Caption在最上面...

MouseMove的效果会颤抖? 真奇怪?试试GetCursor 在ClientToScreen一下,再来做
提取,编辑和轻松评估XPath查询。 XPath的助手很容易提取,编辑,并在任何网页评估XPath查询。 重要提示:安装此扩展后,必须重新加载任何现有的选项卡或重新启动Chrome浏览器扩展工作。 说明: 1.打开一个新的标签,并导航到任何网页。 2.按Ctrl-Shift键-X(或OS X命令移-X),或单击工具栏上的XPath的助手按钮,以打开XPath助手控制台。 3.按住Shift键将鼠标悬停在页面上的元素。查询框将不断更新,以显示鼠标指针下方的元件XPath查询,结果框将显示当前查询的结果。 4.如果需要,请在控制台直接编辑XPath查询。结果框会立即反映更改。 5.重复步骤(2)关闭控制台。 如果控制台在你的方式获得,按住Shift键,然后将鼠标移动到它; 它会移动到页面的相对侧。 一个忠告:当渲染HTML表格,浏览器插入人工标记到DOM,这将在随后通过该扩展提取查询显示出来。 Extract, edit, and evaluate XPath queries with ease. XPath Helper makes it easy to extract, edit, and evaluate XPath queries on any webpage. IMPORTANT: After installing this extension, you must reload any existing tabs or restart Chrome for the extension to work. Instructions: 1. Open a new tab and navigate to any webpage. 2. Hit Ctrl-Shift-X (or Command-Shift-X on OS X), or click the XPath Helper button in the toolbar, to open the XPath Helper console. 3. Hold down Shift as you mouse over elements on the page. The query box will continuously update to show the XPath query for the element below the mouse pointer, and the results box will show the results for the current query. 4. If desired, edit the XPath query directly in the console. The results box will immediately reflect your changes. 5. Repeat step (2) to close the console. If the console gets in your way, hold down Shift and then move your mouse over it; it will move to the opposite side of the page. One word of caution: When rendering HTML tables, Chrome inserts artificial tags into the DOM, which will consequently show up in queries extracted by this extension.

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧