大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
从来只有高分辨率下为低分辨率环境开发程序的。既然开发环境是低分辨率,那就只能利用代码初始化各个控件的位置和大小了。随测随改。
成都创新互联公司是一家专业提供遂川企业网站建设,专注与成都网站设计、做网站、成都外贸网站建设公司、H5开发、小程序制作等业务。10年已为遂川众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
vb.net设置一个窗体为,宽度不能调节,而高度可以调节,
代码设置方法:
Dim form_width As Integer = Me.Width
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.Width form_width Then
Me.Width = form_width
'Debug.Print(TimeString "-" CStr(Me.Width))
End If
End Sub
vb.net,即Visual Basic.NET是基于微软.NET Framework之上的面向对象的编程语言。其在调试时是以解释型语言方式运作,而输出为EXE程序是是以编译型语言方式运作。可以看作是Visual Basic在.Net Framework平台上的升级版本,增强了对面向对象的支持。
屏幕的长宽就是屏幕的分辨率,用下面的代码实现,每句后面已添加注释
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 '获取屏幕高度
Me.Height = My.Computer.Screen.Bounds.Height
Me.Width = My.Computer.Screen.Bounds.Width
这是设置窗体的长宽和屏幕的分辨率一样大小,相当于全屏。
如果Me.WindowState=FormWindowState.Maximized的话,只是单纯的将窗体最大化,但恢复窗口大小后窗体的大小实际上还和原来一样大。
VB.NET的特点
1.真正成为面向对象以及支持继承性的语言。
2.窗体设计器支持可视化继承,并且包含了许多新的特性,比如自动改变窗体大小、资源本地化支持、数据类工具内在支持XML数据。
3.直接建立在.NET的框架结构上,因此开发人员可以充分利用所有.NET平台特性,也可以与其他的.NET语言交互。
4.为Windows应用程序提供了XCOPY部署,开发者不再需要为DLL的版本问题担忧。
窗体初始化时,设定Windowstate= maximized.
窗体分辨率仍然可以设成1920x1080。设计元素的时候拖拽,或者使用代码初始化控件。
这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率
实例代码,有需要的朋友可以参考一下
复制代码
代码如下:
Private
Declare
Function
GetDeviceCaps
Lib
"gdi32"
(ByVal
hdc
As
Long,
ByVal
nIndex
As
Long)
As
Long
Private
Declare
Function
ChangeDisplaySettings
Lib
"user32"
Alias
"ChangeDisplaySettingsA"
(lpDevMode
As
Any,
ByVal
dwflags
As
Long)
As
Long
Private
Const
CCDEVICENAME
As
Long
=
32
Private
Const
CCFORMNAME
As
Long
=
32
Private
Const
DM_BITSPERPEL
As
Long
=
H40000
Private
Const
DM_PELSWIDTH
As
Long
=
H80000
Private
Const
DM_PELSHEIGHT
As
Long
=
H100000
Private
Const
DM_DISPLAYFLAGS
As
Long
=
H200000
Private
Const
DM_DISPLAYFREQUENCY
=
H400000
Private
Const
CDS_FORCE
As
Long
=
H80000000
Private
Const
BITSPIXEL
As
Long
=
12
Private
Const
HORZRES
As
Long
=
8
Private
Const
VERTRES
As
Long
=
10
Private
Const
VREFRESH
=
116
Private
Type
DEVMODE
dmDeviceName
As
String
*
CCDEVICENAME
dmSpecVersion
As
Integer
dmDriverVersion
As
Integer
dmSize
As
Integer
dmDriverExtra
As
Integer
dmFields
As
Long
dmOrientation
As
Integer
dmPaperSize
As
Integer
dmPaperLength
As
Integer
dmPaperWidth
As
Integer
dmScale
As
Integer
dmCopies
As
Integer
dmDefaultSource
As
Integer
dmPrintQuality
As
Integer
dmColor
As
Integer
dmDuplex
As
Integer
dmYResolution
As
Integer
dmTTOption
As
Integer
dmCollate
As
Integer
dmFormName
As
String
*
CCFORMNAME
dmUnusedPadding
As
Integer
dmBitsPerPel
As
Integer
dmPelsWidth
As
Long
dmPelsHeight
As
Long
dmDisplayFlags
As
Long
dmDisplayFrequency
As
Long
End
Type
Private
Sub
cmdChangeDesktopMode_Click()
Dim
DM
As
DEVMODE
With
DM
.dmPelsWidth
=
CInt(txtNewWidth.Text)
.dmPelsHeight
=
CInt(txtNewHeight.Text)
.dmBitsPerPel
=
CInt(txtNewColor.Text)
.dmDisplayFrequency
=
CInt(txtNewFreq.Text)
.dmFields
=
DM_PELSWIDTH
Or
DM_PELSHEIGHT
Or
DM_BITSPERPEL
Or
DM_DISPLAYFREQUENCY
.dmSize
=
LenB(DM)
End
With
If
ChangeDisplaySettings(DM,
CDS_FORCE)
Then
MsgBox
"错误!不支持此模式!"
End
If
End
Sub
Private
Sub
Form_Load()
txtOldWidth.Text
=
GetDeviceCaps(Me.hdc,
HORZRES)
txtOldHeight.Text
=
GetDeviceCaps(Me.hdc,
VERTRES)
txtOldColor.Text
=
GetDeviceCaps(Me.hdc,
BITSPIXEL)
txtOldFreq.Text
=
GetDeviceCaps(Me.hdc,
VREFRESH)
End
Sub