vb 中怎么获取屏幕的长宽啊?

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:42:44
我想编一个桌面小动画,可是在不同分辨率下就可能走出屏幕或是走不到全部位置(我想要是能用两个数值来记录桌面长度(a)和宽度(b)并能输出(print a,b)一下就好了),请高手帮忙啊?

屏幕的长宽就是屏幕的分辨率,用下面的代码实现,每句后面已添加注释
Dim x As Integer, y As Integer '定义2个整数型变量
x = Screen.Width / Screen.TwipsPerPixelX '获取屏幕宽度
y = Screen.Height / Screen.TwipsPerPixelY '获取屏幕高度
上面是vb的语法
下面是Vb.Net的语法:
Dim x, y As Long '定义2个整数型变量
x = Screen.PrimaryScreen.Bounds.Width.ToString '获取屏幕宽度
y = Screen.PrimaryScreen.Bounds.Height.ToString '获取屏幕高度

vb 中获取屏幕的宽高

Dim w As Integer
Dim h As Integer
w = Screen.Width \Screen.TwipsperPixelX
h = Screen.Height \Screen.TwipsperPixelY

w 是屏幕 宽
h 是屏幕 高
就是分辨率中的数值

screen.width 其他的可以类推