当前位置:网站首页>vb. Net changes with the window, scales the size of the control and maintains its relative position
vb. Net changes with the window, scales the size of the control and maintains its relative position
2022-07-06 08:43:00 【Flying_】
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
' You have to use ClientSize, Out of commission Size, because Size Including the width and height of the window frame , This is a fixed value , Cannot be calculated into the scaling factor
' Otherwise, when it shrinks to a certain extent , The calculation proportion of the size and position of the control is wrong
_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
effect
边栏推荐
猜你喜欢
Chrome浏览器的crash问题
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
目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
Screenshot in win10 system, win+prtsc save location
2022.02.13 - NC004. Print number of loops
生成器参数传入参数
游戏解包的危害及资源加密的重要性
深度剖析C语言数据在内存中的存储
Cisp-pte practice explanation
Light of domestic games destroyed by cracking
随机推荐
同一局域网的手机和电脑相互访问,IIS设置
Image, CV2 read the conversion and size resize change of numpy array of pictures
查看局域网中电脑设备
Navicat Premium 创建MySql 创建存储过程
2022.02.13 - NC002. sort
优秀的软件测试人员,都具备这些能力
Indentation of tabs and spaces when writing programs for sublime text
Deep analysis of C language pointer
如何进行接口测试测?有哪些注意事项?保姆级解读
C語言雙指針——經典題型
Roguelike game into crack the hardest hit areas, how to break the bureau?
China high purity silver nitrate Market Research and investment strategy report (2022 Edition)
【Nvidia开发板】常见问题集 (不定时更新)
Mobile phones and computers on the same LAN access each other, IIS settings
2022.02.13 - NC004. Print number of loops
hutool优雅解析URL链接并获取参数
China Light conveyor belt in-depth research and investment strategy report (2022 Edition)
Tcp/ip protocol
Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
Function coritization