永发信息网

怎样用VB写移动文本框

答案:3  悬赏:50  手机版
解决时间 2021-07-26 13:40
  • 提问者网友:疯子也有疯子的情调
  • 2021-07-26 00:43
怎样用VB写移动文本框
最佳答案
  • 五星知识达人网友:何以畏孤独
  • 2021-07-26 01:05

这是通过鼠标移动代码: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 Sub


Private 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


这里只做了,一个方向移动,你可以类推,还有加上到端的判断!!


希望对你有帮助!

全部回答
  • 1楼网友:老鼠爱大米
  • 2021-07-26 04:03

把下面代码放到按钮事件里!

TextBox1.top +=10;

TextBox1.left +=10;

  • 2楼网友:深街酒徒
  • 2021-07-26 02:35

Text1.Move 50, 50, 50, 50

左 顶 宽 高

这几个参数设置好了就可以移动了,不知道你是不是这个意思

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯