答案:这是通过鼠标移动代码: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
Const WM_SYSCOMMAND = &H112
Const SC_MOVE = &HF010&
Const HTCAPTION = 2
Private Sub MoveWindow(ByVal hwnd As Long)
Dim ret As Long
ReleaseCapture
ret = SendMessage(Text1.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
End Sub
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveWindow hwnd
End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveWindow hwnd
End Sub
当然你可以通过时钟控制
dim i as integer
private sub form_load()
timer1.interval=100
end sub
private sub timer1_timer()
i=i+1
textbox1.top+=1
end sub
这里只做了,一个方向移动,你可以类推,还有加上到端的判断!!
希望对你有帮助!
Text1.Move 50, 50, 50, 50
左 顶 宽 高
这几个参数设置好了就可以移动了,不知道你是不是这个意思
把下面代码放到按钮事件里!
TextBox1.top +=10;
TextBox1.left +=10;
上一个:VB-textbox控件问题
下一个:VB编程有什么用?