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


边栏推荐
- Problems in loading and saving pytorch trained models
- Deep anatomy of C language -- C language keywords
- Image,cv2读取图片的numpy数组的转换和尺寸resize变化
- MySQL learning record 10getting started with JDBC
- 【MySQL】鎖
- tree树的精准查询
- JVM 快速入门
- China polyether amine Market Forecast and investment strategy report (2022 Edition)
- Modify the video name from the name mapping relationship in the table
- 移位运算符
猜你喜欢
随机推荐
2022.02.13 - NC003. Design LRU cache structure
JVM quick start
The harm of game unpacking and the importance of resource encryption
【MySQL】日志
C語言雙指針——經典題型
sublime text中conda环境中plt.show无法弹出显示图片的问题
How to conduct interface test? What are the precautions? Nanny level interpretation
【ROS】usb_ Cam camera calibration
Leetcode question brushing (5.28) hash table
win10系统中的截图,win+prtSc保存位置
Synchronized solves problems caused by sharing
China Light conveyor belt in-depth research and investment strategy report (2022 Edition)
Image, CV2 read the conversion and size resize change of numpy array of pictures
Screenshot in win10 system, win+prtsc save location
Bottom up - physical layer
被破解毁掉的国产游戏之光
egg. JS getting started navigation: installation, use and learning
MySQL learning record 07 index (simple understanding)
Deep learning: derivation of shallow neural networks and deep neural networks
[NVIDIA development board] FAQ (updated from time to time)









