VB 屏幕分辨率 有加分!
需要在form4被激活的时候改成1024*768Form_Unload(CancelAsInteger)里面再改回来最好是可以直接复制的先谢过了有加分!怎么获得原来的分辨...
需要在form4被激活的时候改成1024*768
Form_Unload(Cancel As Integer)里面再改回来
最好是可以直接复制的
先谢过了
有加分!
怎么获得原来的分辨率呀?
不一定是800*600呀? 展开
Form_Unload(Cancel As Integer)里面再改回来
最好是可以直接复制的
先谢过了
有加分!
怎么获得原来的分辨率呀?
不一定是800*600呀? 展开
1个回答
展开全部
'设置显示器分辨率
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Long
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const ENUM_CURRENT_SETTINGS = -1
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
Dim DevM As DEVMODE
Private Sub Form_Load()
EnumDisplaySettings 0, 0, DevM
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 1024 '设定成想要的分辨率
DevM.dmPelsHeight = 768
ChangeDisplaySettings DevM, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
EnumDisplaySettings 0, 0, DevM
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 800 '设回原分辨率
DevM.dmPelsHeight = 600
ChangeDisplaySettings DevM, 0
End Sub
'获取分辨率
Private Sub Command1_Click()
EnumDisplaySettings 0, ENUM_CURRENT_SETTINGS, DevM
Print DevM.dmPelsWidth & "×" & DevM.dmPelsHeight
End Sub
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Long
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const ENUM_CURRENT_SETTINGS = -1
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
Dim DevM As DEVMODE
Private Sub Form_Load()
EnumDisplaySettings 0, 0, DevM
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 1024 '设定成想要的分辨率
DevM.dmPelsHeight = 768
ChangeDisplaySettings DevM, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
EnumDisplaySettings 0, 0, DevM
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 800 '设回原分辨率
DevM.dmPelsHeight = 600
ChangeDisplaySettings DevM, 0
End Sub
'获取分辨率
Private Sub Command1_Click()
EnumDisplaySettings 0, ENUM_CURRENT_SETTINGS, DevM
Print DevM.dmPelsWidth & "×" & DevM.dmPelsHeight
End Sub
东莞大凡
2024-11-14 广告
2024-11-14 广告
标定板认准大凡光学科技,专业生产研发厂家,专业从事光学影像测量仪,光学投影测量仪.光学三维测量仪,光学二维测量仪,光学二维测量仪,光学三维测量仪,光学二维测量仪.的研发生产销售。东莞市大凡光学科技有限公司创立于 2018 年,公司总部坐落于...
点击进入详情页
本回答由东莞大凡提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询