vb中command控件怎样实现:鼠标点击后跟着鼠标移动?

[复制链接]
查看11 | 回复3 | 2007-8-16 11:35:03 | 显示全部楼层 |阅读模式
不对的,用图片控件做棋子要好得多!自己可以定义坐标,判断你点击的坐标,用MOVE方法移动棋子。
回复

使用道具 举报

千问 | 2007-8-16 11:35:03 | 显示全部楼层
以上没有一个是确切的要command1与form配合起来用,包你鼠标到哪里,command1到那里.我有现成的程序代码.不过只提供给朋友.
回复

使用道具 举报

千问 | 2007-8-16 11:35:03 | 显示全部楼层
Dim Xx, YyPrivate Sub command1_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single)If Button = 1 ThenXx = XYy = yEnd IfEnd SubPrivate Sub command1_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)If Button = 1 ThenCommand1.Left = X - Xx + Command1.LeftCommand1.Top = y - Yy + Command1.TopEnd IfEnd Sub好吧,我也加一种Dim Xx, YyPrivate Sub command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 ThenCommand1.Left = X - Xx + Command1.LeftCommand1.Top = y - Yy + Command1.TopElseXx=xYy=yEnd IfEnd Sub
回复

使用道具 举报

千问 | 2007-8-16 11:35:03 | 显示全部楼层
Private Sub Command1_DragDrop(Source As Control, X As Single, Y As Single)Source.Move (X - Source.Width / 2), (Y - Source.Height / 2)End SubPrivate Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Command1.Drag 1End SubPrivate Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Command1.Drag 2End Sub
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行