当前位置:网站首页>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
效果
边栏推荐
- Detailed explanation of heap sorting
- Sort according to a number in a string in a column of CSV file
- 生成器参数传入参数
- IOT -- interpreting the four tier architecture of the Internet of things
- Verrouillage [MySQL]
- [MySQL] log
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- Research Report on supply and demand and development prospects of China's high purity aluminum market (2022 Edition)
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- 704 binary search
猜你喜欢
随机推荐
JS inheritance method
C語言雙指針——經典題型
Research Report on supply and demand and development prospects of China's high purity aluminum market (2022 Edition)
C语言双指针——经典题型
2022.02.13 - NC001. Reverse linked list
LDAP application (4) Jenkins access
Browser thread
目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
logback1.3. X configuration details and Practice
【Nvidia开发板】常见问题集 (不定时更新)
[NVIDIA development board] FAQ (updated from time to time)
VMware 虚拟化集群
同一局域网的手机和电脑相互访问,IIS设置
Rviz仿真时遇到机器人瞬间回到世界坐标原点的问题及可能原因
Image,cv2读取图片的numpy数组的转换和尺寸resize变化
Screenshot in win10 system, win+prtsc save location
Delay initialization and sealing classes
JS pure function
Colorlog结合logging打印有颜色的日志
win10系统中的截图,win+prtSc保存位置