VB图片拖拽问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 18:56:32
form1中画三个图片框picturebox1 picturebox2 picturebox3
formload时 picturebox1 picturebox2 中分别置入图片 1.jpg 2.jpg
问题1: 图片怎么在三个图片框中自由拖拽 并且 图片框中若有图片时 图片不得覆盖 比如 1.jpg可从picturebox1 拖到picturebox3中(其中无图片)但不能拖拽到picturebox2中(其中有2.jpg)
问题2:图片框能旋转改变角度麽 若能 如何实现

1. 三个 PictureBox 的 OLEDragMode 设为 Automatic,OLEDropMode 设为 Manual.然后 以Picture3为例,写如下代码,其余类推。

Private Sub Picture3_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Picture3.Picture = 0 Then
Picture3.Picture = Data.GetData(vbCFBitmap)
End If
End Sub

2. 不能。只能用 平面解析几何中的坐标系旋转公式来进行变换,而且角度不是90°的整数倍时还要进行裁剪。

可以设置一个标志数,比如Flag(1 to 3) as boolean,有图片的时候置为1,没有图片置0,拖拽的时候显示一个拖动的图标,比如从1拖到3,先判断3的Flag(3)是否为1,不是1的话,放开鼠标,执行,Picutre3.picture=picture1.picture
Picture1.picture=Loadpicture

图片框不能改变角度

Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
If Picture1.Picture = Empty Then
Picture1.Picture = Source.Picture
Source.Picture = LoadPicture("")
End If
'三个图片框DragMode=1
End Sub
Private Sub Picture2_DragDrop(Source As Control, X As Single, Y As Single)
If Picture2.Picture = Empty Then