VB中怎样让picturebox中的控件、图像等随窗体的改变而改变大小?代码尽量少一些,我百度了很久都不行
3个回答
展开全部
你如何改变窗体?拖动?最大化?
根据改变窗体的方式不同,代码是不同的。
根据改变窗体的方式不同,代码是不同的。
更多追问追答
追问
拖动,,用鼠标在窗体边拖动改变大小
追答
已经做好,没有问题,现在给你注释一下。
Dim W As Single, H As Single
Dim TP As Single, LP As Single, WP As Single, HP As Single
Dim WLabel1 As Single, HLabel1 As Single, TLabel1 As Single, LLabel1 As Single
Dim WText1 As Single, HText1 As Single, TText1 As Single, LText1 As Single
Private Sub Form_Load()
W = Me.Width: H = Me.Height
WP = Picture1.Width: HP = Picture1.Height: TP = Picture1.Top: LP = Picture1.Left
WLabel1 = Label1.Width: HLabel1 = Label1.Height: TLabel1 = Label1.Top: LLabel1 = Label1.Left
WText1 = Text1.Width: HText1 = Text1.Height: TText1 = Text1.Top: LText1 = Text1.Left
End Sub
Private Sub Form_Resize()
Dim WL As Single, HL As Single
WL = Me.ScaleWidth / W: HL = Me.ScaleHeight / H '拖动后的比例,不是一定值!
Picture1.Width = WP * WL: Picture1.Left = LP * WL
Picture1.Height = HP * HL: Picture1.Top = TP * HL
Label1.Left = LLabel1 * WL: Label1.Width = WLabel1 * WL
Label1.Top = TLabel1 * HL: Label1.Height = HLabel1 * HL
Text1.Left = LText1 * WL: Text1.Width = WText1 * WL
Text1.Top = TText1 * HL: Text1.Height = HText1 * HL
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Resize()
Picture1.Height = Form1.ScaleHeight
Picture1.Left = Form1.ScaleLeft
Picture1.Top = Form1.ScaleTop
Picture1.Width = Form1.ScaleWidth
End Sub
Picture1.Height = Form1.ScaleHeight
Picture1.Left = Form1.ScaleLeft
Picture1.Top = Form1.ScaleTop
Picture1.Width = Form1.ScaleWidth
End Sub
更多追问追答
追问
控件不会动,不会改变大小啊
追答
你拖动窗体看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询