''' summary多屏显示屏幕设置/summary
科尔沁右翼前网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。成都创新互联公司2013年开创至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司。
''' param name="obj"目标窗体/param
''' param name="scrIndex"由0开始的屏幕索引,0为主屏幕/param
Private Sub ShowScreens(obj As Form, scrIndex As Integer)
Dim arr As Screen() = Screen.AllScreens
If scrIndex arr.Length Then
obj.Left += arr(scrIndex).Bounds.X
Else
Dim mess As String = "当前屏幕索引超出范围,是否要显示在最后一个屏幕?"
Dim result As DialogResult = _
MessageBox.Show(mess, "信息提示", _
MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If result = Windows.Forms.DialogResult.Yes Then _
obj.Left += arr(arr.Length - 1).Bounds.X
End Sub
多屏幕的显示,屏幕的宽度相当等于N屏幕的宽度之和,更改窗体的X坐标就能控制窗体显示在哪个屏幕上。
两个显示器显示有两种模式,一种是
双屏
复制,另一种是扩展。
你这个只能用第二种方式。你需要把要在另一个显示器上显示的窗体的Location设置在主显示器全屏时的右边就可以了.其实就是桌面的向右延伸。
在主显示上拖一下窗体就明白了!
在项目中右键点击添加窗体。在代码中需要显示该窗体的地方写入如下代码:“form2.show()”form2是你窗体的name属性……
我做了几行。
对无标题栏的窗体,或者不从标题栏移动的情况下可用。
有标题栏并且点住标题栏移动则不理想。
代码如下,仅供参考。
1、建立模块。
option
explicit
public
oldproc
as
long
public
declare
function
setwindowlong
lib
"user32"
alias
"setwindowlonga"
(byval
hwnd
as
long,
byval
nindex
as
long,
byval
dwnewlong
as
long)
as
long
public
declare
function
sendmessage
lib
"user32"
alias
"sendmessagea"
(byval
hwnd
as
long,
byval
wmsg
as
long,
byval
wparam
as
long,
byref
lparam
as
any)
as
long
public
declare
function
callwindowproc
lib
"user32"
alias
"callwindowproca"
(byval
lpprevwndfunc
as
long,
byval
hwnd
as
long,
byval
msg
as
any,
byval
wparam
as
any,
byval
lparam
as
any)
as
long
public
const
wm_move
=
h3
public
const
wm_lbuttondown
=
h201
public
const
wm_lbuttonup
=
h202
public
const
gwl_wndproc
=
(-4)
public
bnhwnd
as
long
public
function
newproc(byval
hwnd
as
long,
byval
msg
as
long,
byval
wp
as
long,
byval
lp
as
long)
as
long
if
msg
=
wm_move
then
'捕获窗体移动事件
sendmessage
bnhwnd,
wm_lbuttondown,
1,
sendmessage
bnhwnd,
wm_lbuttonup,
1,
'将消息发送到按纽,使其发生click事件
end
if
newproc
=
callwindowproc(oldproc,
hwnd,
msg,
wp,
lp)
end
function
2、在窗体上有一个按钮(名称为eventbn)
dim
原垂直
as
single,
原水平
as
single
private
sub
eventbn_click()
msgbox
"移动了"
end
sub
private
sub
form_load()
form2.show
form3.show
bnhwnd
=
eventbn.hwnd
'获得按纽句丙
oldproc
=
setwindowlong(me.hwnd,
gwl_wndproc,
addressof
newproc)
eventbn.visible
=
false
end
sub
private
sub
form_mousedown(button
as
integer,
shift
as
integer,
x
as
single,
y
as
single)
if
button
=
1
then
原垂直
=
me.top
+
y
原水平
=
me.left
+
x
end
if
end
sub
private
sub
form_mouseup(button
as
integer,
shift
as
integer,
x
as
single,
y
as
single)
me.top
=
me.top
-
原垂直
+
y
me.left
=
me.left
-
原水平
+
x
form2.top
=
form2.top
-
原垂直
+
y
form2.left
=
form2.left
-
原水平
+
x
form3.top
=
form3.top
-
原垂直
+
y
form3.left
=
form3.left
-
原水平
+
x
end
sub
3、其他窗体基本都这样。