以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  用setbouds设置窗口位置的时候,屏幕中间怎么定义?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=66548)

--  作者:晕了快扶我
--  发布时间:2015/4/9 11:07:00
--  用setbouds设置窗口位置的时候,屏幕中间怎么定义?

SetBounds(x, y, Width, Height)

x: 窗口水平位置
y: 窗口垂直位置
Width: 窗口宽度
Height: 窗口高度

 

 

X,Y怎么定位到屏幕中央呢?像系统的CenterScreen


--  作者:Bin
--  发布时间:2015/4/9 11:11:00
--  
用不着SetBounds  设置默认位置为CenterScreen  打开就在中间了


非要用SetBounds  的话

获取系统分辨率 
MessageBox.show(System.Windows.Forms.SystemInformation.PrimaryMonitorSize.height)
MessageBox.show(System.Windows.Forms.SystemInformation.PrimaryMonitorSize.width)

然后计算窗口的宽度 算出中间坐标即可.  

--  作者:晕了快扶我
--  发布时间:2015/4/9 11:32:00
--  

这个坐标取的的是窗口正中的点吗?


--  作者:晕了快扶我
--  发布时间:2015/4/9 11:33:00
--  
还是左上角的点?
--  作者:Bin
--  发布时间:2015/4/9 11:34:00
--  
左上角的点
--  作者:晕了快扶我
--  发布时间:2015/4/9 11:39:00
--  

 

Dim sp As WinForm.SplitContainer = e.Form.Controls("SplitContainer2")
Dim h As Integer = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.height
Dim w As Integer =System.Windows.Forms.SystemInformation.PrimaryMonitorSize.width
Dim ch As Integer = e.Form.height
Dim cw As Integer = e.Form.width
If e.sender.Text = "打开筛选树"
    sp.Panel1.Collapsed = False
    e.Sender.Text = "关闭筛选树"
\'e.Form.SetBounds(w-cw/2h-ch/2,949,540)
MessageBox.show(h-ch/2)
MessageBox.show(w-cw/2)
ElseIf e.Sender.Text = "关闭筛选树"
    sp.Panel1.Collapsed = True
    e.Sender.Text = "打开筛选树"
e.Form.SetBounds(ch,cw,791,540)
End If

 

怎么还是不行啊图片点击可在新窗口打开查看搞晕了

[此贴子已经被作者于2015/4/9 11:45:28编辑过]

--  作者:Bin
--  发布时间:2015/4/9 11:42:00
--  
e.Form.SetBounds(ch,cw,791,540)   第一个 和第二个参数是坐标,而不是窗口大小
e.Form.SetBounds(w/2-791/2,h/2-540/2,791,540)

[此贴子已经被作者于2015/4/9 11:43:21编辑过]

--  作者:晕了快扶我
--  发布时间:2015/4/9 11:49:00
--  
e.Form.SetBounds(w/2-791/2,h/2-540/2,791,540)

 

还是发生了位移啊


--  作者:Bin
--  发布时间:2015/4/9 11:49:00
--  
不会的,上例子.


--  作者:晕了快扶我
--  发布时间:2015/4/9 12:00:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:窗口测试.foxdb