📄 运用directx设置程序运行时屏幕分辨率.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3510
ClientLeft = 60
ClientTop = 345
ClientWidth = 6570
LinkTopic = "Form1"
ScaleHeight = 3510
ScaleWidth = 6570
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 375
Left = 3240
TabIndex = 2
Top = 2250
Width = 1005
End
Begin VB.CommandButton cmdSet
Caption = "设置"
Height = 375
Left = 1710
TabIndex = 1
Top = 2250
Width = 1140
End
Begin VB.ListBox LisDisMode
Height = 1320
Left = 1350
TabIndex = 0
Top = 540
Width = 5100
End
Begin VB.Label Label1
Caption = "屏幕分辨率:"
Height = 240
Left = 90
TabIndex = 3
Top = 540
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DisplayModesEnum As DirectDrawEnumModes '定义所需的DirectX 对象
Dim DDSd2 As DDSURFACEDESC2
Dim dxSet As New DirectX7
Dim ddSet As DirectDraw7
Dim IntWid(100) As Long '显示模式数组
Dim IntHig(100) As Long
Dim IntBD(100) As Long
Dim IntRefR(100) As Long
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSet_Click()
Dim intSel As Integer
intSel = LisDisMode.ListIndex + 1
'设置 ddSet 的协作水平
Call ddSet.SetCooperativeLevel(Me.hWnd, DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE)
'设置显示分辨率
ddSet.SetDisplayMode IntWid(intSel), IntHig(intSel), IntBD(intSel), IntRefR(intSel), DDSDM_DEFAULT
End Sub
Private Sub Form_Load()
' ddSet 获取 dxSet 建立的 DirectDraw 对象
Set ddSet = dxSet.DirectDrawCreate("")
'设置 ddSet 协作水平
ddSet.SetCooperativeLevel Me.hWnd, DDSCL_NORMAL
' DisplayModesEnum 获取 ddSet 的显示模式
Set DisplayModesEnum = ddSet.GetDisplayModesEnum(0, DDSd2)
' 在 LisDisMode 中添加本机支持的分辨率
For i = 1 To DisplayModesEnum.GetCount()
DisplayModesEnum.GetItem i, DDSd2
LisDisMode.AddItem "显示模式" & Str(i) & ": 宽度" & Str(DDSd2.lWidth) & "高度" & Str(DDSd2.lHeight) & "色彩深度" & Str(DDSd2.ddpfPixelFormat.lRGBBitCount) & "刷新率" & Str(DDSd2.lRefreshRate)
IntWid(i) = Str(DDSd2.lWidth)
IntHig(i) = Str(DDSd2.lHeight)
IntBD(i) = Str(DDSd2.ddpfPixelFormat.lRGBBitCount)
IntRefR(i) = Str(DDSd2.lRefreshRate)
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -