home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 7.0 / Dx7.bin / DXF / samples / multimedia / vbsamples / d3dim / src / imcontrol / frmselectres.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-21  |  6.9 KB  |  222 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSelectRes 
  3.    ClientHeight    =   4215
  4.    ClientLeft      =   60
  5.    ClientTop       =   345
  6.    ClientWidth     =   4680
  7.    Icon            =   "frmSelectRes.frx":0000
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4215
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.ComboBox cmbResolution 
  13.       Height          =   315
  14.       Left            =   120
  15.       Style           =   2  'Dropdown List
  16.       TabIndex        =   7
  17.       Top             =   1320
  18.       Width           =   4455
  19.    End
  20.    Begin VB.CommandButton Command2 
  21.       Caption         =   "Cancel"
  22.       Height          =   495
  23.       Left            =   2400
  24.       TabIndex        =   6
  25.       Top             =   3480
  26.       Width           =   975
  27.    End
  28.    Begin VB.CommandButton Command1 
  29.       Caption         =   "OK"
  30.       Default         =   -1  'True
  31.       Height          =   495
  32.       Left            =   3480
  33.       TabIndex        =   5
  34.       Top             =   3480
  35.       Width           =   975
  36.    End
  37.    Begin VB.CheckBox chFPS 
  38.       Caption         =   " Show Frames Per Second"
  39.       Height          =   195
  40.       Left            =   120
  41.       TabIndex        =   4
  42.       Top             =   2760
  43.       Width           =   3015
  44.    End
  45.    Begin VB.ComboBox cmbRasterizer 
  46.       Height          =   315
  47.       Left            =   120
  48.       Style           =   2  'Dropdown List
  49.       TabIndex        =   3
  50.       Top             =   2160
  51.       Width           =   4455
  52.    End
  53.    Begin VB.ComboBox cmbHardware 
  54.       Height          =   315
  55.       Left            =   120
  56.       Style           =   2  'Dropdown List
  57.       TabIndex        =   2
  58.       Top             =   480
  59.       Width           =   4455
  60.    End
  61.    Begin VB.Label Label3 
  62.       Caption         =   "FullScreen Resolution"
  63.       Height          =   255
  64.       Left            =   120
  65.       TabIndex        =   8
  66.       Top             =   960
  67.       Width           =   2415
  68.    End
  69.    Begin VB.Label Label2 
  70.       Caption         =   "Rasterizers"
  71.       Height          =   255
  72.       Left            =   120
  73.       TabIndex        =   1
  74.       Top             =   1800
  75.       Width           =   2895
  76.    End
  77.    Begin VB.Label Label1 
  78.       Caption         =   "Display Hardware"
  79.       Height          =   255
  80.       Left            =   120
  81.       TabIndex        =   0
  82.       Top             =   120
  83.       Width           =   2415
  84.    End
  85. Attribute VB_Name = "frmSelectRes"
  86. Attribute VB_GlobalNameSpace = False
  87. Attribute VB_Creatable = False
  88. Attribute VB_PredeclaredId = True
  89. Attribute VB_Exposed = False
  90. Option Explicit
  91. Dim dx As New DirectX7
  92. Dim m_dden As DirectDrawEnum
  93. Dim m_modes  As DirectDrawEnumModes
  94. Dim m_rast As Direct3DEnumDevices
  95. Dim m_sDDrawGuid As String
  96. Dim m_sRasterizerGuid As String
  97. Dim m_w As Long
  98. Dim m_h As Long
  99. Dim m_bpp As Long
  100. Dim m_bShowFps As Boolean
  101. Dim m_bFullscreen As Boolean
  102. Dim m_bCommit As Boolean
  103. Public Function ChangeConfig(ByRef sDDrawGuid As String, ByRef sRasterizerGuid As String, ByRef w As Long, ByRef h As Long, ByRef bpp As Long, ByRef bFullscreen As Boolean, ByRef bShowfps As Boolean) As Boolean
  104.     m_bFullscreen = bFullscreen
  105.     m_bShowFps = bShowfps
  106.     m_bpp = bpp
  107.     m_w = w
  108.     m_h = h
  109.     m_sDDrawGuid = sDDrawGuid
  110.     m_sRasterizerGuid = sRasterizerGuid
  111.         
  112.     FillDDrawEnum
  113.     Dim i As Long
  114.     'Find the DDraw Guid in the combo list
  115.     For i = 1 To m_dden.GetCount()
  116.         If UCase(m_dden.GetGuid(i)) = UCase(sDDrawGuid) Then
  117.             cmbHardware.ListIndex = i - 1
  118.             Exit For
  119.         End If
  120.     Next
  121.     'if we did not find one- select the first one in the list
  122.     If i = m_dden.GetCount + 1 Then cmbHardware.ListIndex = 0
  123.     'Find rasterizer in the combo list
  124.     For i = 1 To m_rast.GetCount()
  125.         If UCase(m_rast.GetGuid(i)) = UCase(sRasterizerGuid) Then
  126.             cmbRasterizer.ListIndex = i - 1
  127.             Exit For
  128.         End If
  129.     Next
  130.     'if we did not find one- select the first one in the list
  131.     If i = m_rast.GetCount + 1 Then cmbRasterizer.ListIndex = 0
  132.     'Find the resolution
  133.     Dim info As DDSURFACEDESC2
  134.     If Not bFullscreen Then
  135.         cmbResolution.ListIndex = 0
  136.     Else
  137.         
  138.         For i = 1 To m_modes.GetCount()
  139.             m_modes.GetItem i, info
  140.             If info.ddpfPixelFormat.lRGBBitCount = bpp And _
  141.                 info.lWidth = w And _
  142.                 info.lHeight = h Then
  143.                 cmbResolution.ListIndex = i
  144.                 Exit For
  145.             End If
  146.         Next
  147.                 
  148.     End If
  149.     Me.Show 1
  150.     If m_bCommit Then
  151.         If cmbResolution.ListIndex = 0 Then
  152.             bFullscreen = False
  153.         Else
  154.         
  155.             m_modes.GetItem cmbResolution.ListIndex, info
  156.         
  157.             If (info.ddpfPixelFormat.lRGBBitCount <= 8) Then
  158.                 MsgBox "D3DIM application must run in 16 bpp color or better"
  159.                 Exit Function
  160.             End If
  161.         
  162.             bFullscreen = True
  163.                
  164.         End If
  165.         bpp = info.ddpfPixelFormat.lRGBBitCount
  166.         w = info.lWidth
  167.         h = info.lHeight
  168.            
  169.         bShowfps = chFPS.Value
  170.         
  171.                                 
  172.         sDDrawGuid = m_dden.GetGuid(cmbHardware.ListIndex + 1)
  173.         sRasterizerGuid = m_rast.GetGuid(cmbRasterizer.ListIndex + 1)
  174.         ChangeConfig = True
  175.     End If
  176.     Set m_dden = Nothing
  177.     Set m_modes = Nothing
  178.     Set m_rast = Nothing
  179. End Function
  180. Private Sub cmbHardware_Click()
  181.     SelectDDraw cmbHardware.ListIndex
  182. End Sub
  183. Sub FillDDrawEnum()
  184.     Dim i As Long
  185.     Set m_dden = dx.GetDDEnum()
  186.     cmbHardware.Clear
  187.     For i = 1 To m_dden.GetCount()
  188.         cmbHardware.AddItem m_dden.GetDescription(i)
  189.     Next
  190.     SelectDDraw 0
  191. End Sub
  192. Sub SelectDDraw(i As Integer)
  193.     Dim dd As DirectDraw7
  194.     Dim desc As DDSURFACEDESC2
  195.     Dim j As Long
  196.     Set dd = dx.DirectDrawCreate(m_dden.GetGuid(i + 1))
  197.     Set m_modes = dd.GetDisplayModesEnum(DDEDM_DEFAULT, desc)
  198.     cmbResolution.Clear
  199.     cmbResolution.AddItem "Window Size with Desktop Resolution"
  200.     For j = 1 To m_modes.GetCount()
  201.         m_modes.GetItem j, desc
  202.         cmbResolution.AddItem Str(desc.lWidth) + " x" + Str(desc.lHeight) + " x" + Str(desc.ddpfPixelFormat.lRGBBitCount)
  203.     Next
  204.     Dim d3d As Direct3D7
  205.     Set d3d = dd.GetDirect3D()
  206.     cmbRasterizer.Clear
  207.     Set m_rast = d3d.GetDevicesEnum()
  208.     For j = 1 To m_rast.GetCount()
  209.         cmbRasterizer.AddItem m_rast.GetDescription(j)
  210.     Next
  211.     cmbResolution.ListIndex = 0
  212.     cmbRasterizer.ListIndex = 0
  213. End Sub
  214. Private Sub Command1_Click()
  215.     m_bCommit = True
  216.     Me.Visible = False
  217. End Sub
  218. Private Sub Command2_Click()
  219.     m_bCommit = False
  220.     Me.Visible = False
  221. End Sub
  222.