当前位置:网站首页>vb.net 随窗口改变,缩放控件大小以及保持相对位置
vb.net 随窗口改变,缩放控件大小以及保持相对位置
2022-07-06 08:38:00 【飞天_】
Public Class Form1
Dim _originClienSize As Size = Nothing
Dim _originBtnSize As Size
Dim _originBtnPos As Point
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'必须使用ClientSize,不能使用Size,因为Size包括窗口框架的宽高,这个是固定值,不能计算到缩放因素里
'不然当缩小到一定程度时,控件的大小和位置计算比例就不对了
_originClienSize = ClientSize
_originBtnSize = Button2.Size
_originBtnPos = Button2.Location
End Sub
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
If _originClienSize <> Nothing Then
Button2.Width = ClientSize.Width / _originClienSize.Width * _originBtnSize.Width
Button2.Height = ClientSize.Height / _originClienSize.Height * _originBtnSize.Height
Dim point As Point = New Point(ClientSize.Width / _originClienSize.Width * _originBtnPos.X, ClientSize.Height / _originClienSize.Height * _originBtnPos.Y)
Button2.Location = point
End If
End Sub
End Class
效果
边栏推荐
- VMware virtualization cluster
- 角色动画(Character Animation)的现状与趋势
- PLT in Matplotlib tight_ layout()
- IoT -- 解读物联网四层架构
- Synchronized solves problems caused by sharing
- Fairguard game reinforcement: under the upsurge of game going to sea, game security is facing new challenges
- C language double pointer -- classic question type
- IOT -- interpreting the four tier architecture of the Internet of things
- Process of obtaining the electronic version of academic qualifications of xuexin.com
- torch建立的网络模型使用torchviz显示
猜你喜欢
随机推荐
What is CSRF (Cross Site Request Forgery)?
Generator parameters incoming parameters
电脑F1-F12用途
3. File operation 3-with
Let the bullets fly for a while
[MySQL] log
Modify the video name from the name mapping relationship in the table
IOT -- interpreting the four tier architecture of the Internet of things
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
logback1.3. X configuration details and Practice
[2022 Guangdong saim] Lagrange interpolation (multivariate function extreme value divide and conquer NTT)
Deep analysis of C language pointer
Computer cleaning, deleted system files
Indentation of tabs and spaces when writing programs for sublime text
深度剖析C语言指针
egg. JS getting started navigation: installation, use and learning
China high purity silver nitrate Market Research and investment strategy report (2022 Edition)
查看局域网中电脑设备
堆排序详解
PC easy to use essential software (used)