加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 08:20:09 所属栏目:百科 来源:网络整理
导读: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 = Scree

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读