当前位置:网站首页>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
效果
边栏推荐
- JS native implementation shuttle box
- LDAP Application Section (4) Jenkins Access
- [MySQL] database stored procedure and storage function clearance tutorial (full version)
- LDAP應用篇(4)Jenkins接入
- 2022.02.13 - NC001. Reverse linked list
- Chrome浏览器的crash问题
- China Light conveyor belt in-depth research and investment strategy report (2022 Edition)
- Leetcode skimming (5.29) hash table
- Precise query of tree tree
- sublime text的编写程序时的Tab和空格缩进问题
猜你喜欢
JS inheritance method
egg. JS project deployment online server
marathon-envs项目环境配置(强化学习模仿参考动作)
Configuring OSPF load sharing for Huawei devices
Crash problem of Chrome browser
【ROS】usb_ Cam camera calibration
TCP/IP协议
swagger设置字段required必填
2022.02.13 - NC002. sort
Fairguard game reinforcement: under the upsurge of game going to sea, game security is facing new challenges
随机推荐
Modify the video name from the name mapping relationship in the table
Light of domestic games destroyed by cracking
Leetcode skimming (5.29) hash table
Sublime text using ctrl+b to run another program without closing other runs
visdom可视化实现与检查介绍
查看局域网中电脑设备
@JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)
After PCD is converted to ply, it cannot be opened in meshlab, prompting error details: ignored EOF
深度剖析C语言数据在内存中的存储
leetcode刷题 (5.31) 字符串
MySQL learning record 07 index (simple understanding)
Synchronized solves problems caused by sharing
2022.02.13 - NC002. sort
游戏解包的危害及资源加密的重要性
[brush questions] top101 must be brushed in the interview of niuke.com
String to leading 0
个人电脑好用必备软件(使用过)
poi追加写EXCEL文件
Browser thread
[NVIDIA development board] FAQ (updated from time to time)