有没有人做过啊

lufan82 2005-08-14 11:22:02
我想做一个方框可以在PICTUREBOX里面移动,双击他的话就将方框里的图片剪下来,不知道怎么下手啊
...全文
112 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
VBDN 2005-08-15
  • 打赏
  • 举报
回复
呵呵,完成了!
点右键的时候会将方框里的图片剪下来显示到Picture2中
在窗体中加入PictureBox2,下面为窗体的代码:
Private Sub Form_Load()
Shape1.Width = 0
Shape1.Height = 0
Shape1.BorderColor = vbRed
Shape1.BorderStyle = 3
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Shape1.Left = X
Shape1.Top = Y
End If
If Button = vbRightButton Then
Picture2.Cls
Picture2.PaintPicture Picture1.Picture, 0, 0, Shape1.Width, Shape1.Height, Shape1.Left, Shape1.Top, Shape1.Width, Shape1.Height
End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Shape1.Width = Abs(X - Shape1.Left)
Shape1.Height = Abs(Y - Shape1.Top)
End If
End Sub
VBDN 2005-08-15
  • 打赏
  • 举报
回复
在窗体中加入一个PictureBox1控件、在PictureBox1控件内放一个Shape1控件。
下边的代码将实现:当你在PictureBox控件内拖动鼠标时,出现一个选取框。
Private Sub Form_Load()
Shape1.Width = 0
Shape1.Height = 0
Shape1.BorderColor = vbRed
Shape1.BorderStyle = 3
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Shape1.Left = X
Shape1.Top = Y
End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Shape1.Width = Abs(X - Shape1.Left)
Shape1.Height = Abs(Y - Shape1.Top)
End If
End Sub
TaiJi1985 2005-08-15
  • 打赏
  • 举报
回复
楼上是对的。

主要就是:
mouse_down
mouse_move

剪用的是 paintpicture

保存要用 savepicture

7,762

社区成员

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

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