前端之家收集整理的这篇文章主要介绍了
vb 无边框窗体拖动,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
rem vb 无边框窗体拖动
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long,_
ByVal wMsg As Long,_
ByVal wParam As Long,_
ByVal lParam As Any) As Long<pre name="code" class="vb"><pre name="code" class="vb">Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Const WM_SYSCOMMAND = &H112
Public Const SC_MOVE = &HF010&
Public Const HTCAPTION = 2
rem 在窗体的最上方,放一个Image控件,设置在最底层,然后改名<span style="font-family: Arial,Helvetica,sans-serif;">ImgDrag,加上以下代码即可</span>
Private Sub ImgDrag_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single)
ReleaseCapture
Call SendMessage(Me.hWnd,WM_SYSCOMMAND,SC_MOVE + HTCAPTION,ByVal 0&)
End Sub
<img src="http://img.blog.csdn.net/20151015000111960?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />