当前位置:网站首页>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
效果


边栏推荐
- JVM quick start
- Process of obtaining the electronic version of academic qualifications of xuexin.com
- Summary of MySQL index failure scenarios
- Restful API design specification
- pytorch训练好的模型在加载和保存过程中的问题
- FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
- 3. File operation 3-with
- [luatos-air551g] 6.2 repair: restart caused by line drawing
- marathon-envs项目环境配置(强化学习模仿参考动作)
- MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
猜你喜欢

IoT -- 解读物联网四层架构

2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers

Deep analysis of C language data storage in memory

View computer devices in LAN

2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Trying to use is on a network resource that is unavailable

角色动画(Character Animation)的现状与趋势

sublime text中conda环境中plt.show无法弹出显示图片的问题

PLT in Matplotlib tight_ layout()
随机推荐
Visual implementation and inspection of visdom
tree树的精准查询
2022.02.13 - NC003. Design LRU cache structure
pytorch训练好的模型在加载和保存过程中的问题
Research and investment forecast report of citronellol industry in China (2022 Edition)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[luatos-air551g] 6.2 repair: restart caused by line drawing
Crash problem of Chrome browser
Sort according to a number in a string in a column of CSV file
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
Light of domestic games destroyed by cracking
移位运算符
China dihydrolaurenol market forecast and investment strategy report (2022 Edition)
FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
游戏解包的危害及资源加密的重要性
2022.02.13 - NC004. Print number of loops
Delay initialization and sealing classes
[brush questions] top101 must be brushed in the interview of niuke.com
Verrouillage [MySQL]
【MySQL】锁