VB 运行时如何使picture控件随窗体放大缩小
我在PictureBox里画实时曲线,问题是在运行时,当鼠标点窗体右下角调整其大小时,怎样才能让picture控件及曲线等比例放大或缩小呢?请前辈们指点。帮人帮到底吧大侠...
我在PictureBox里画实时曲线, 问题是在运行时,当鼠标点窗体右下角调整其大小时,怎样才能让picture控件及曲线等比例放大或缩小呢?请前辈们指点。
帮人帮到底吧大侠~ 你的程序可以实现图片框 缩放,但我加了如下语句,显示坐标系, 坐标系不随窗体缩放啊,你再提示一下吧 谢谢
Private Sub picture1_Click()
Cls
Picture1.Scale (-110, 110)-(110, -110)
Picture1.CurrentX = 105: Picture1.CurrentY = 20: Picture1.Print "x"
Picture1.CurrentX = 10: Picture1.CurrentY = 105: Picture1.Print "y"
For i = -100 To 100 Step 20
If i <> 0 Then
Picture1.CurrentX = 1: Picture1.CurrentY = 7: Picture1.Line -(i, 0)
Picture1.CurrentX = i - 5: Picture1.CurrentY = -5: Picture1.Print i / 10
Else
Picture1.CurrentX = -3: Picture1.CurrentY = -5: Picture1.Print 0
End If
Next i
For i = -100 To 100 Step 20
If i <> 0 Then
Picture1.CurrentX = -15: Picture1.CurrentY = i + 5: Picture1.Print i / 10
Picture1.CurrentX = 7: Picture1.CurrentY = i: Picture1.Line -(0, i)
End If
Next i
End Sub 展开
帮人帮到底吧大侠~ 你的程序可以实现图片框 缩放,但我加了如下语句,显示坐标系, 坐标系不随窗体缩放啊,你再提示一下吧 谢谢
Private Sub picture1_Click()
Cls
Picture1.Scale (-110, 110)-(110, -110)
Picture1.CurrentX = 105: Picture1.CurrentY = 20: Picture1.Print "x"
Picture1.CurrentX = 10: Picture1.CurrentY = 105: Picture1.Print "y"
For i = -100 To 100 Step 20
If i <> 0 Then
Picture1.CurrentX = 1: Picture1.CurrentY = 7: Picture1.Line -(i, 0)
Picture1.CurrentX = i - 5: Picture1.CurrentY = -5: Picture1.Print i / 10
Else
Picture1.CurrentX = -3: Picture1.CurrentY = -5: Picture1.Print 0
End If
Next i
For i = -100 To 100 Step 20
If i <> 0 Then
Picture1.CurrentX = -15: Picture1.CurrentY = i + 5: Picture1.Print i / 10
Picture1.CurrentX = 7: Picture1.CurrentY = i: Picture1.Line -(0, i)
End If
Next i
End Sub 展开
5个回答
展开全部
Option Explicit
Dim pT!, pL!, pW!, pH!
Private Sub Form_Load()
'保存picture控件的Top、Left、Width和Height属性
pT = Picture1.Top
pL = Picture1.Left
pW = Picture1.Width
pH = Picture1.Height
End Sub
Private Sub Form_Resize()
Form1.ScaleHeight = 4000
Form1.ScaleWidth = 4000
'设置Picture1的位置和大小
Picture1.Move pL, pT, pW, pH
End Sub
其中
Form1.ScaleHeight = 4000
Form1.ScaleWidth = 4000
中的4000你根据自己窗体和控件初始大小调整,需要自己调整的。
Dim pT!, pL!, pW!, pH!
Private Sub Form_Load()
'保存picture控件的Top、Left、Width和Height属性
pT = Picture1.Top
pL = Picture1.Left
pW = Picture1.Width
pH = Picture1.Height
End Sub
Private Sub Form_Resize()
Form1.ScaleHeight = 4000
Form1.ScaleWidth = 4000
'设置Picture1的位置和大小
Picture1.Move pL, pT, pW, pH
End Sub
其中
Form1.ScaleHeight = 4000
Form1.ScaleWidth = 4000
中的4000你根据自己窗体和控件初始大小调整,需要自己调整的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在窗体Resize事件中根据窗体的宽度改变控件的宽高就行了。
例如
Private Sub Form_Resize()
picture1.width=form1.width/10
picture1.height=form1.height/10
这样控件根据窗体的大小缩放。同样,相对位置也可以这样
例如
Private Sub Form_Resize()
picture1.width=form1.width/10
picture1.height=form1.height/10
这样控件根据窗体的大小缩放。同样,相对位置也可以这样
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
首先在设计时确定窗体与Picturebox之间的关系,例如Picture1.Left=? Picture1.Top=? Picture1.Width 与 me.Width 的比例关系,Picture1.Height 与 me.Height 的比例关系
那么,在Form_Resize事件中就可以按比例放大或缩小控件尺寸,但控件位置不变,例如
Dim X As Single, Y As Single
Private Sub Form_Load()
X = Picture1.Height / Me.Height
Y = Picture1.Width / Me.Width
End Sub
Private Sub Form_Resize()
Picture1.Height = Me.Height * X
Picture1.Width = Me.Width * Y
End Sub
那么,在Form_Resize事件中就可以按比例放大或缩小控件尺寸,但控件位置不变,例如
Dim X As Single, Y As Single
Private Sub Form_Load()
X = Picture1.Height / Me.Height
Y = Picture1.Width / Me.Width
End Sub
Private Sub Form_Resize()
Picture1.Height = Me.Height * X
Picture1.Width = Me.Width * Y
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub PicPrintZB()
Picture1.Cls
Picture1.Scale (-110, 110)-(110, -110)
Picture1.CurrentX = 105: Picture1.CurrentY = 20: Picture1.Print "x"
Picture1.CurrentX = 10: Picture1.CurrentY = 105: Picture1.Print "y"
For I = -100 To 100 Step 20
If I <> 0 Then
Picture1.CurrentX = 1: Picture1.CurrentY = 7: Picture1.Line -(I, 0)
Picture1.CurrentX = I - 5: Picture1.CurrentY = -5: Picture1.Print I / 10
Else
Picture1.CurrentX = -3: Picture1.CurrentY = -5: Picture1.Print 0
End If
Next I
For I = -100 To 100 Step 20
If I <> 0 Then
Picture1.CurrentX = -15: Picture1.CurrentY = I + 5: Picture1.Print I / 10
Picture1.CurrentX = 7: Picture1.CurrentY = I: Picture1.Line -(0, I)
End If
Next I
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
Private Sub Form_Resize()
Picture1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
PicPrintZB
End Sub
Picture1.Cls
Picture1.Scale (-110, 110)-(110, -110)
Picture1.CurrentX = 105: Picture1.CurrentY = 20: Picture1.Print "x"
Picture1.CurrentX = 10: Picture1.CurrentY = 105: Picture1.Print "y"
For I = -100 To 100 Step 20
If I <> 0 Then
Picture1.CurrentX = 1: Picture1.CurrentY = 7: Picture1.Line -(I, 0)
Picture1.CurrentX = I - 5: Picture1.CurrentY = -5: Picture1.Print I / 10
Else
Picture1.CurrentX = -3: Picture1.CurrentY = -5: Picture1.Print 0
End If
Next I
For I = -100 To 100 Step 20
If I <> 0 Then
Picture1.CurrentX = -15: Picture1.CurrentY = I + 5: Picture1.Print I / 10
Picture1.CurrentX = 7: Picture1.CurrentY = I: Picture1.Line -(0, I)
End If
Next I
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
Private Sub Form_Resize()
Picture1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
PicPrintZB
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
设置picturebox的Autosize为true即可
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |