VB.Net 设置子窗口在父窗口居中显示

前端之家收集整理的这篇文章主要介绍了VB.Net 设置子窗口在父窗口居中显示前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Private Function SetLocation(ByVal insForm As Form) As Point 'Screen.AllScreens[0]是获取当前显示器设备窗口的第一个 Dim insScreen As Screen = Screen.AllScreens(0) If (Not Me.OwnerForm Is Nothing) Then '获取控件父窗口的屏幕 insScreen = Screen.FromControl(Me) End If '当前屏幕的宽度 - 子页面的宽度 Dim width As Integer = (insScreen.WorkingArea.Width - insForm.Width) '当前屏幕的高度 - 子页面的高度 Dim height As Integer = (insScreen.WorkingArea.Height - insForm.Height) '居中 Dim x As Integer = (insScreen.WorkingArea.X + CInt(Math.Round(CDbl((CDbl(width) / 2))))) Dim y As Integer = (insScreen.WorkingArea.Y + CInt(Math.Round(CDbl((CDbl(height) / 2))))) '启动模式 insForm.StartPosition = FormStartPosition.Manual '返回 Return New Point(x,y) End Function
原文链接:https://www.f2er.com/vb/259222.html

猜你在找的VB相关文章