//----------------------------------------------------------------------------- // Name: MultisampleTypeChanged // Desc: Respond to a change of selected multisample type. //----------------------------------------------------------------------------- void CD3DSettingsDialog::MultisampleTypeChanged( void ) { D3DMULTISAMPLE_TYPE mst = (D3DMULTISAMPLE_TYPE)PtrToUlong( ComboBoxSelected( IDC_MULTISAMPLE_COMBO ) ); m_d3dSettings.SetMultisampleType( mst ); // Set up max quality for this mst D3DDeviceCombo* pDeviceCombo = m_d3dSettings.PDeviceCombo(); DWORD maxQuality = 0; for( UINT ims = 0; ims < pDeviceCombo->pMultiSampleTypeList->Count(); ims++ ) { D3DMULTISAMPLE_TYPE msType = *(D3DMULTISAMPLE_TYPE*)pDeviceCombo->pMultiSampleTypeList->GetPtr(ims); if( msType == mst ) { maxQuality = *(DWORD*)pDeviceCombo->pMultiSampleQualityList->GetPtr(ims); break; } } ComboBoxClear( IDC_MULTISAMPLE_QUALITY_COMBO ); for( UINT msq = 0; msq < maxQuality; msq++ ) { TCHAR str[100]; wsprintf( str, TEXT("%d"), msq ); ComboBoxAdd( IDC_MULTISAMPLE_QUALITY_COMBO, UlongToPtr( msq ), str ); if( msq == m_d3dSettings.MultisampleQuality() ) ComboBoxSelect( IDC_MULTISAMPLE_QUALITY_COMBO, UlongToPtr( msq ) ); } if (!ComboBoxSomethingSelected( IDC_MULTISAMPLE_QUALITY_COMBO ) && ComboBoxCount( IDC_MULTISAMPLE_QUALITY_COMBO ) > 0) { ComboBoxSelectIndex( IDC_MULTISAMPLE_QUALITY_COMBO, 0 ); } }
//----------------------------------------------------------------------------- // Name: AdapterChanged // Desc: Respond to a change of selected adapter. //----------------------------------------------------------------------------- void CD3DSettingsDialog::AdapterChanged( void ) { D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO ); if( pAdapterInfo == NULL ) return; if( m_d3dSettings.IsWindowed ) m_d3dSettings.pWindowed_AdapterInfo = pAdapterInfo; else m_d3dSettings.pFullscreen_AdapterInfo = pAdapterInfo; // Update device combo box ComboBoxClear( IDC_DEVICE_COMBO ); for( UINT idi = 0; idi < pAdapterInfo->pDeviceInfoList->Count(); idi++ ) { D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)pAdapterInfo->pDeviceInfoList->GetPtr(idi); ComboBoxAdd( IDC_DEVICE_COMBO, pDeviceInfo, D3DDevTypeToString( pDeviceInfo->DevType ) ); if( pDeviceInfo->DevType == m_d3dSettings.DevType() ) ComboBoxSelect( IDC_DEVICE_COMBO, pDeviceInfo ); } if( !ComboBoxSomethingSelected( IDC_DEVICE_COMBO ) && ComboBoxCount( IDC_DEVICE_COMBO ) > 0 ) { ComboBoxSelectIndex( IDC_DEVICE_COMBO, 0 ); } }
//----------------------------------------------------------------------------- // Name: ResolutionChanged // Desc: Respond to a change of selected resolution by rebuilding the // refresh rate list. //----------------------------------------------------------------------------- void CD3DSettingsDialog::ResolutionChanged( void ) { if (m_d3dSettings.IsWindowed) return; D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO ); if( pAdapterInfo == NULL ) return; // Update settingsNew with new resolution DWORD dwResolutionData = PtrToUlong( ComboBoxSelected( IDC_RESOLUTION_COMBO ) ); UINT width = LOWORD( dwResolutionData ); UINT height = HIWORD( dwResolutionData ); m_d3dSettings.Fullscreen_DisplayMode.Width = width; m_d3dSettings.Fullscreen_DisplayMode.Height = height; // Update refresh rate list based on new resolution D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) ); ComboBoxClear( IDC_REFRESHRATE_COMBO ); for( UINT idm = 0; idm < pAdapterInfo->pDisplayModeList->Count(); idm++ ) { D3DDISPLAYMODE displayMode = *(D3DDISPLAYMODE*)pAdapterInfo->pDisplayModeList->GetPtr(idm); if (displayMode.Format == adapterFormat && displayMode.Width == width && displayMode.Height == height) { TCHAR strRefreshRate[50]; if( displayMode.RefreshRate == 0 ) lstrcpy( strRefreshRate, TEXT("Default Rate") ); else _sntprintf_s( strRefreshRate, 50, 50, TEXT("%d Hz"), displayMode.RefreshRate ); strRefreshRate[49] = 0; if( !ComboBoxContainsText( IDC_REFRESHRATE_COMBO, strRefreshRate ) ) { ComboBoxAdd( IDC_REFRESHRATE_COMBO, UlongToPtr( displayMode.RefreshRate ), strRefreshRate ); if (m_d3dSettings.Fullscreen_DisplayMode.RefreshRate == displayMode.RefreshRate) ComboBoxSelect( IDC_REFRESHRATE_COMBO, UlongToPtr( displayMode.RefreshRate ) ); } } } if (!ComboBoxSomethingSelected( IDC_REFRESHRATE_COMBO ) && ComboBoxCount( IDC_REFRESHRATE_COMBO ) > 0) { ComboBoxSelectIndex( IDC_REFRESHRATE_COMBO, 0 ); } }
//----------------------------------------------------------------------------- // Name: DepthStencilBufferFormatChanged // Desc: Respond to a change of selected depth/stencil buffer format. //----------------------------------------------------------------------------- void CD3DSettingsDialog::DepthStencilBufferFormatChanged( void ) { D3DFORMAT fmt = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) ); if( m_pEnumeration->AppUsesDepthBuffer ) m_d3dSettings.SetDepthStencilBufferFormat( fmt ); // Build multisample list D3DDeviceCombo* pDeviceCombo = m_d3dSettings.PDeviceCombo(); ComboBoxClear( IDC_MULTISAMPLE_COMBO ); for( UINT ims = 0; ims < pDeviceCombo->pMultiSampleTypeList->Count(); ims++ ) { D3DMULTISAMPLE_TYPE msType = *(D3DMULTISAMPLE_TYPE*)pDeviceCombo->pMultiSampleTypeList->GetPtr(ims); // check for DS/MS conflicts BOOL bConflictFound = FALSE; for( UINT iConf = 0; iConf < pDeviceCombo->pDSMSConflictList->Count(); iConf++ ) { D3DDSMSConflict* pDSMSConf = (D3DDSMSConflict*)pDeviceCombo->pDSMSConflictList->GetPtr(iConf); if( pDSMSConf->DSFormat == fmt && pDSMSConf->MSType == msType ) { bConflictFound = TRUE; break; } } if( !bConflictFound ) { ComboBoxAdd( IDC_MULTISAMPLE_COMBO, (void*)msType, MultisampleTypeToString(msType) ); if( msType == m_d3dSettings.MultisampleType() ) ComboBoxSelect( IDC_MULTISAMPLE_COMBO, (void*)msType ); } } if (!ComboBoxSomethingSelected( IDC_MULTISAMPLE_COMBO ) && ComboBoxCount( IDC_MULTISAMPLE_COMBO ) > 0) { ComboBoxSelectIndex( IDC_MULTISAMPLE_COMBO, 0 ); } }
// Handles window messages for the graphics settings dialog. INT_PTR DeviceEnumeration::SettingsDialogProc( HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam ) { switch( msg ) { case WM_INITDIALOG: { // Display the adapter details and its driver version. char version[16]; sprintf( version, "%d", LOWORD( m_adapter.DriverVersion.LowPart ) ); Edit_SetText( GetDlgItem( dialog, IDC_DISPLAY_ADAPTER ), m_adapter.Description ); Edit_SetText( GetDlgItem( dialog, IDC_DRIVER_VERSION ), version ); // Check if the settings script has anything in it. if( m_settingsScript->GetBoolData( "windowed" ) == NULL ) { // The settings script is empty, so default to windowed mode. CheckDlgButton( dialog, IDC_WINDOWED, m_windowed = true ); } else { // Load the window mode state. CheckDlgButton( dialog, IDC_WINDOWED, m_windowed = *m_settingsScript->GetBoolData( "windowed" ) ); CheckDlgButton( dialog, IDC_FULLSCREEN, !m_windowed ); // Check if running in fullscreen mode. if( m_windowed == false ) { // Enable all the fullscreen controls. EnableWindow( GetDlgItem( dialog, IDC_VSYNC ), true ); EnableWindow( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ), true ); EnableWindow( GetDlgItem( dialog, IDC_RESOLUTION ), true ); EnableWindow( GetDlgItem( dialog, IDC_REFRESH_RATE ), true ); // Load the vsync state. CheckDlgButton( dialog, IDC_VSYNC, m_vsync = *m_settingsScript->GetBoolData( "vsync" ) ); // Fill in the display formats combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) if( !ComboBoxContainsText( dialog, IDC_DISPLAY_FORMAT, m_displayModes->GetCurrent()->bpp ) ) ComboBoxAdd( dialog, IDC_DISPLAY_FORMAT, (void*)m_displayModes->GetCurrent()->mode.Format, m_displayModes->GetCurrent()->bpp ); ComboBoxSelect( dialog, IDC_DISPLAY_FORMAT, *m_settingsScript->GetNumberData( "bpp" ) ); char text[16]; // Fill in the resolutions combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_RESOLUTION ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) { if( m_displayModes->GetCurrent()->mode.Format == (D3DFORMAT)PtrToUlong( ComboBoxSelected( dialog, IDC_COLOUR_DEPTH ) ) ) { sprintf( text, "%d x %d", m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ); if (!ComboBoxContainsText( dialog, IDC_RESOLUTION, text ) ) ComboBoxAdd( dialog, IDC_RESOLUTION, (void*)MAKELONG( m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ), text ); } } ComboBoxSelect( dialog, IDC_RESOLUTION, *m_settingsScript->GetNumberData( "resolution" ) ); // Fill in the refresh rates combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_REFRESH_RATE ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) { if( (DWORD)MAKELONG( m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ) == (DWORD)PtrToUlong( ComboBoxSelected( dialog, IDC_RESOLUTION ) ) ) { sprintf( text, "%d Hz", m_displayModes->GetCurrent()->mode.RefreshRate ); if (!ComboBoxContainsText( dialog, IDC_REFRESH_RATE, text ) ) ComboBoxAdd( dialog, IDC_REFRESH_RATE, (void*)m_displayModes->GetCurrent()->mode.RefreshRate, text ); } } ComboBoxSelect( dialog, IDC_REFRESH_RATE, *m_settingsScript->GetNumberData( "refresh" ) ); } } return true; } case WM_COMMAND: { switch( LOWORD(wparam) ) { case IDOK: { // Store the details of the selected display mode. m_selectedDisplayMode.Width = LOWORD( PtrToUlong( ComboBoxSelected( dialog, IDC_RESOLUTION ) ) ); m_selectedDisplayMode.Height = HIWORD( PtrToUlong( ComboBoxSelected( dialog, IDC_RESOLUTION ) ) ); m_selectedDisplayMode.RefreshRate = PtrToUlong( ComboBoxSelected( dialog, IDC_REFRESH_RATE ) ); m_selectedDisplayMode.Format = (D3DFORMAT)PtrToUlong( ComboBoxSelected( dialog, IDC_DISPLAY_FORMAT ) ); m_windowed = IsDlgButtonChecked( dialog, IDC_WINDOWED ) ? true : false; m_vsync = IsDlgButtonChecked( dialog, IDC_VSYNC ) ? true : false; // Destroy the display modes list. SAFE_DELETE( m_displayModes ); // Get the selected index from each combo box. long bpp = ComboBox_GetCurSel( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ) ); long resolution = ComboBox_GetCurSel( GetDlgItem( dialog, IDC_RESOLUTION ) ); long refresh = ComboBox_GetCurSel( GetDlgItem( dialog, IDC_REFRESH_RATE ) ); // Check if the settings script has anything in it. if( m_settingsScript->GetBoolData( "windowed" ) == NULL ) { // Add all the settings to the script. m_settingsScript->AddVariable( "windowed", VARIABLE_BOOL, &m_windowed ); m_settingsScript->AddVariable( "vsync", VARIABLE_BOOL, &m_vsync ); m_settingsScript->AddVariable( "bpp", VARIABLE_NUMBER, &bpp ); m_settingsScript->AddVariable( "resolution", VARIABLE_NUMBER, &resolution ); m_settingsScript->AddVariable( "refresh", VARIABLE_NUMBER, &refresh ); } else { // Set all the settings. m_settingsScript->SetVariable( "windowed", &m_windowed ); m_settingsScript->SetVariable( "vsync", &m_vsync ); m_settingsScript->SetVariable( "bpp", &bpp ); m_settingsScript->SetVariable( "resolution", &resolution ); m_settingsScript->SetVariable( "refresh", &refresh ); } // Save all the settings out to the settings script. m_settingsScript->SaveScript(); // Destroy the settings script. SAFE_DELETE( m_settingsScript ); // Close the dialog. EndDialog( dialog, IDOK ); return true; } case IDCANCEL: { // Destroy the display modes list. SAFE_DELETE( m_displayModes ); // Destroy the settings script. SAFE_DELETE( m_settingsScript ); EndDialog( dialog, IDCANCEL ); return true; } case IDC_COLOUR_DEPTH: { if( CBN_SELCHANGE == HIWORD(wparam) ) { char res[16]; DWORD selectedRes = (DWORD)PtrToUlong( ComboBoxSelected( dialog, IDC_RESOLUTION ) ); // Update the resolution combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_RESOLUTION ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) { if( m_displayModes->GetCurrent()->mode.Format == (D3DFORMAT)PtrToUlong( ComboBoxSelected( dialog, IDC_COLOUR_DEPTH ) ) ) { sprintf( res, "%d x %d", m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ); if( !ComboBoxContainsText( dialog, IDC_RESOLUTION, res ) ) { ComboBoxAdd( dialog, IDC_RESOLUTION, (void*)MAKELONG( m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ), res ); if( selectedRes == (DWORD)MAKELONG( m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ) ) ComboBoxSelect( dialog, IDC_RESOLUTION, (void*)selectedRes ); } } } if( ComboBoxSelected( dialog, IDC_RESOLUTION ) == NULL ) ComboBoxSelect( dialog, IDC_RESOLUTION, 0 ); } return true; } case IDC_RESOLUTION: { if( CBN_SELCHANGE == HIWORD(wparam) ) { char refresh[16]; DWORD selectedRefresh = (DWORD)PtrToUlong( ComboBoxSelected( dialog, IDC_REFRESH_RATE ) ); // Update the refresh rate combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_REFRESH_RATE ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) { if( (DWORD)MAKELONG( m_displayModes->GetCurrent()->mode.Width, m_displayModes->GetCurrent()->mode.Height ) == (DWORD)PtrToUlong( ComboBoxSelected( dialog, IDC_RESOLUTION ) ) ) { sprintf( refresh, "%d Hz", m_displayModes->GetCurrent()->mode.RefreshRate ); if( !ComboBoxContainsText( dialog, IDC_REFRESH_RATE, refresh ) ) { ComboBoxAdd( dialog, IDC_REFRESH_RATE, (void*)m_displayModes->GetCurrent()->mode.RefreshRate, refresh ); if( selectedRefresh == m_displayModes->GetCurrent()->mode.RefreshRate ) ComboBoxSelect( dialog, IDC_REFRESH_RATE, (void*)selectedRefresh ); } } } if( ComboBoxSelected( dialog, IDC_REFRESH_RATE ) == NULL ) ComboBoxSelect( dialog, IDC_REFRESH_RATE, 0 ); } return true; } case IDC_WINDOWED: case IDC_FULLSCREEN: { // Check if the user has change to windowed or fullscreen mode. if( IsDlgButtonChecked( dialog, IDC_WINDOWED ) ) { // Clear and disable all the fullscreen controls. ComboBox_ResetContent( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ) ); ComboBox_ResetContent( GetDlgItem( dialog, IDC_RESOLUTION ) ); ComboBox_ResetContent( GetDlgItem( dialog, IDC_REFRESH_RATE ) ); CheckDlgButton( dialog, IDC_VSYNC, false ); EnableWindow( GetDlgItem( dialog, IDC_VSYNC ), false ); EnableWindow( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ), false ); EnableWindow( GetDlgItem( dialog, IDC_RESOLUTION ), false ); EnableWindow( GetDlgItem( dialog, IDC_REFRESH_RATE ), false ); } else { // Enable all the fullscreen controls. EnableWindow( GetDlgItem( dialog, IDC_VSYNC ), true ); EnableWindow( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ), true ); EnableWindow( GetDlgItem( dialog, IDC_RESOLUTION ), true ); EnableWindow( GetDlgItem( dialog, IDC_REFRESH_RATE ), true ); // Fill in the display formats combo box. ComboBox_ResetContent( GetDlgItem( dialog, IDC_DISPLAY_FORMAT ) ); m_displayModes->Iterate( true ); while( m_displayModes->Iterate() ) { if( !ComboBoxContainsText( dialog, IDC_DISPLAY_FORMAT, m_displayModes->GetCurrent()->bpp ) ) ComboBoxAdd( dialog, IDC_DISPLAY_FORMAT, (void*)m_displayModes->GetCurrent()->mode.Format, m_displayModes->GetCurrent()->bpp ); } ComboBoxSelect( dialog, IDC_DISPLAY_FORMAT, 0 ); } return true; } } } } return false; }
//----------------------------------------------------------------------------- // Name: BackBufferFormatChanged // Desc: Respond to a change of selected back buffer format by rebuilding // the depth/stencil format list, multisample type list, and vertex // processing type list. //----------------------------------------------------------------------------- void CD3DSettingsDialog::BackBufferFormatChanged( void ) { D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO ); D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) ); D3DFORMAT backBufferFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_BACKBUFFERFORMAT_COMBO ) ); if( pDeviceInfo == NULL ) return; for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ ) { D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc); if (pDeviceCombo->IsWindowed == m_d3dSettings.IsWindowed && pDeviceCombo->AdapterFormat == adapterFormat && pDeviceCombo->BackBufferFormat == backBufferFormat) { if( m_d3dSettings.IsWindowed ) m_d3dSettings.pWindowed_DeviceCombo = pDeviceCombo; else m_d3dSettings.pFullscreen_DeviceCombo = pDeviceCombo; ComboBoxClear( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ); if( m_pEnumeration->AppUsesDepthBuffer ) { for( UINT ifmt = 0; ifmt < pDeviceCombo->pDepthStencilFormatList->Count(); ifmt++ ) { D3DFORMAT fmt = *(D3DFORMAT*)pDeviceCombo->pDepthStencilFormatList->GetPtr(ifmt); ComboBoxAdd( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, (void*)fmt, D3DUtil_D3DFormatToString(fmt) ); if( fmt == m_d3dSettings.DepthStencilBufferFormat() ) ComboBoxSelect( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, (void*)fmt ); } if (!ComboBoxSomethingSelected( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) && ComboBoxCount( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) > 0) { ComboBoxSelectIndex( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, 0 ); } } else { EnableWindow( GetDlgItem( m_hDlg, IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ), false ); ComboBoxAdd( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, NULL, TEXT("(not used)") ); ComboBoxSelectIndex( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, 0 ); } ComboBoxClear( IDC_VERTEXPROCESSING_COMBO ); for( UINT ivpt = 0; ivpt < pDeviceCombo->pVertexProcessingTypeList->Count(); ivpt++ ) { VertexProcessingType vpt = *(VertexProcessingType*)pDeviceCombo->pVertexProcessingTypeList->GetPtr(ivpt); ComboBoxAdd( IDC_VERTEXPROCESSING_COMBO, (void*)vpt, VertexProcessingTypeToString(vpt) ); if( vpt == m_d3dSettings.GetVertexProcessingType() ) ComboBoxSelect( IDC_VERTEXPROCESSING_COMBO, (void*)vpt ); } if (!ComboBoxSomethingSelected( IDC_VERTEXPROCESSING_COMBO ) && ComboBoxCount( IDC_VERTEXPROCESSING_COMBO ) > 0) { ComboBoxSelectIndex( IDC_VERTEXPROCESSING_COMBO, 0 ); } ComboBoxClear( IDC_PRESENTINTERVAL_COMBO ); for( UINT ipi = 0; ipi < pDeviceCombo->pPresentIntervalList->Count(); ipi++ ) { UINT pi = *(UINT*)pDeviceCombo->pPresentIntervalList->GetPtr(ipi); ComboBoxAdd( IDC_PRESENTINTERVAL_COMBO, UlongToPtr( pi ), PresentIntervalToString(pi) ); if( pi == m_d3dSettings.PresentInterval() ) ComboBoxSelect( IDC_PRESENTINTERVAL_COMBO, UlongToPtr( pi ) ); } if (!ComboBoxSomethingSelected( IDC_PRESENTINTERVAL_COMBO ) && ComboBoxCount( IDC_PRESENTINTERVAL_COMBO ) > 0) { ComboBoxSelectIndex( IDC_PRESENTINTERVAL_COMBO, 0 ); } break; } } }
//----------------------------------------------------------------------------- // Name: AdapterFormatChanged // Desc: Respond to a change of selected adapter format by rebuilding the // resolution list and back buffer format list. Updating the selected // resolution and back buffer format will trigger updates of the rest // of the dialog. //----------------------------------------------------------------------------- void CD3DSettingsDialog::AdapterFormatChanged( void ) { if( !IsDlgButtonChecked( m_hDlg, IDC_WINDOW ) ) { D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO ); D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) ); m_d3dSettings.Fullscreen_DisplayMode.Format = adapterFormat; ComboBoxClear( IDC_RESOLUTION_COMBO ); for( UINT idm = 0; idm < pAdapterInfo->pDisplayModeList->Count(); idm++ ) { D3DDISPLAYMODE displayMode = *(D3DDISPLAYMODE*)pAdapterInfo->pDisplayModeList->GetPtr(idm); if (displayMode.Format == adapterFormat) { DWORD dwResolutionData; TCHAR strResolution[50]; dwResolutionData = MAKELONG( displayMode.Width, displayMode.Height ); _sntprintf_s( strResolution, 50, 50, TEXT("%d by %d"), displayMode.Width, displayMode.Height ); strResolution[49] = 0; if (!ComboBoxContainsText( IDC_RESOLUTION_COMBO, strResolution ) ) { ComboBoxAdd( IDC_RESOLUTION_COMBO, ULongToPtr( dwResolutionData ), strResolution ); if (m_d3dSettings.Fullscreen_DisplayMode.Width == displayMode.Width && m_d3dSettings.Fullscreen_DisplayMode.Height == displayMode.Height) { ComboBoxSelect( IDC_RESOLUTION_COMBO, ULongToPtr( dwResolutionData ) ); } } } } if (!ComboBoxSomethingSelected( IDC_RESOLUTION_COMBO ) && ComboBoxCount( IDC_RESOLUTION_COMBO ) > 0) { ComboBoxSelectIndex( IDC_RESOLUTION_COMBO, 0 ); } } // Update backbuffer format combo box D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO ); if( pDeviceInfo == NULL ) return; ComboBoxClear( IDC_BACKBUFFERFORMAT_COMBO ); for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ ) { D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc); if (pDeviceCombo->IsWindowed == m_d3dSettings.IsWindowed && pDeviceCombo->AdapterFormat == m_d3dSettings.DisplayMode().Format) { if (!ComboBoxContainsText( IDC_BACKBUFFERFORMAT_COMBO, D3DUtil_D3DFormatToString( pDeviceCombo->BackBufferFormat ) ) ) { ComboBoxAdd( IDC_BACKBUFFERFORMAT_COMBO, (void*)pDeviceCombo->BackBufferFormat, D3DUtil_D3DFormatToString( pDeviceCombo->BackBufferFormat ) ); if (pDeviceCombo->BackBufferFormat == m_d3dSettings.BackBufferFormat() ) ComboBoxSelect( IDC_BACKBUFFERFORMAT_COMBO, (void*)pDeviceCombo->BackBufferFormat ); } } } if (!ComboBoxSomethingSelected( IDC_BACKBUFFERFORMAT_COMBO ) && ComboBoxCount( IDC_BACKBUFFERFORMAT_COMBO ) > 0) { ComboBoxSelectIndex( IDC_BACKBUFFERFORMAT_COMBO, 0 ); } }
//----------------------------------------------------------------------------- // Name: WindowedFullscreenChanged // Desc: Respond to a change of windowed/fullscreen state by rebuilding the // adapter format list, resolution list, and refresh rate list. // Updating the selected adapter format will trigger updates of the // rest of the dialog. //----------------------------------------------------------------------------- void CD3DSettingsDialog::WindowedFullscreenChanged( void ) { D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO ); D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO ); if( pAdapterInfo == NULL || pDeviceInfo == NULL ) return; if( IsDlgButtonChecked( m_hDlg, IDC_WINDOW ) ) { m_d3dSettings.IsWindowed = true; m_d3dSettings.pWindowed_AdapterInfo = pAdapterInfo; m_d3dSettings.pWindowed_DeviceInfo = pDeviceInfo; // Update adapter format combo box ComboBoxClear( IDC_ADAPTERFORMAT_COMBO ); ComboBoxAdd( IDC_ADAPTERFORMAT_COMBO, (void*)m_d3dSettings.Windowed_DisplayMode.Format, D3DUtil_D3DFormatToString( m_d3dSettings.Windowed_DisplayMode.Format ) ); ComboBoxSelectIndex( IDC_ADAPTERFORMAT_COMBO, 0 ); EnableWindow( GetDlgItem( m_hDlg, IDC_ADAPTERFORMAT_COMBO ), false ); // Update resolution combo box DWORD dwResolutionData; TCHAR strResolution[50]; dwResolutionData = MAKELONG( m_d3dSettings.Windowed_DisplayMode.Width, m_d3dSettings.Windowed_DisplayMode.Height ); _sntprintf_s( strResolution, 50, 50, TEXT("%d by %d"), m_d3dSettings.Windowed_DisplayMode.Width, m_d3dSettings.Windowed_DisplayMode.Height ); strResolution[49] = 0; ComboBoxClear( IDC_RESOLUTION_COMBO ); ComboBoxAdd( IDC_RESOLUTION_COMBO, ULongToPtr(dwResolutionData), strResolution ); ComboBoxSelectIndex( IDC_RESOLUTION_COMBO, 0 ); EnableWindow( GetDlgItem( m_hDlg, IDC_RESOLUTION_COMBO ), false ); // Update refresh rate combo box TCHAR strRefreshRate[50]; if( m_d3dSettings.Windowed_DisplayMode.RefreshRate == 0 ) lstrcpy( strRefreshRate, TEXT("Default Rate") ); else _sntprintf_s( strRefreshRate, 50, 50, TEXT("%d Hz"), m_d3dSettings.Windowed_DisplayMode.RefreshRate ); strRefreshRate[49] = 0; ComboBoxClear( IDC_REFRESHRATE_COMBO ); ComboBoxAdd( IDC_REFRESHRATE_COMBO, ULongToPtr(m_d3dSettings.Windowed_DisplayMode.RefreshRate), strRefreshRate ); ComboBoxSelectIndex( IDC_REFRESHRATE_COMBO, 0 ); EnableWindow( GetDlgItem( m_hDlg, IDC_REFRESHRATE_COMBO ), false ); } else { m_d3dSettings.IsWindowed = false; m_d3dSettings.pFullscreen_AdapterInfo = pAdapterInfo; m_d3dSettings.pFullscreen_DeviceInfo = pDeviceInfo; // Update adapter format combo box ComboBoxClear( IDC_ADAPTERFORMAT_COMBO ); for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ ) { D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc); if( pDeviceCombo->IsWindowed ) continue; D3DFORMAT adapterFormat = pDeviceCombo->AdapterFormat; if( !ComboBoxContainsText( IDC_ADAPTERFORMAT_COMBO, D3DUtil_D3DFormatToString( adapterFormat ) ) ) { ComboBoxAdd( IDC_ADAPTERFORMAT_COMBO, (void*)adapterFormat, D3DUtil_D3DFormatToString( adapterFormat ) ); if( adapterFormat == m_d3dSettings.Fullscreen_DisplayMode.Format ) { ComboBoxSelect( IDC_ADAPTERFORMAT_COMBO, (void*)adapterFormat ); } } } if( !ComboBoxSomethingSelected( IDC_ADAPTERFORMAT_COMBO ) && ComboBoxCount( IDC_ADAPTERFORMAT_COMBO ) > 0 ) { ComboBoxSelectIndex( IDC_ADAPTERFORMAT_COMBO, 0 ); } EnableWindow( GetDlgItem( m_hDlg, IDC_ADAPTERFORMAT_COMBO), true ); // Update resolution combo box EnableWindow( GetDlgItem( m_hDlg, IDC_RESOLUTION_COMBO), true ); // Update refresh rate combo box EnableWindow( GetDlgItem( m_hDlg, IDC_REFRESHRATE_COMBO), true ); } }
//----------------------------------------------------------------------------- // Name: DialogProc // Desc: Handle window messages in the dialog. //----------------------------------------------------------------------------- INT_PTR CD3DSettingsDialog::DialogProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { UNREFERENCED_PARAMETER( lParam ); switch( msg ) { case WM_INITDIALOG: { m_hDlg = hDlg; // Fill adapter combo box. Updating the selected adapter will trigger // updates of the rest of the dialog. for( UINT iai = 0; iai < m_pEnumeration->m_pAdapterInfoList->Count(); iai++ ) { D3DAdapterInfo* pAdapterInfo; pAdapterInfo = (D3DAdapterInfo*)m_pEnumeration->m_pAdapterInfoList->GetPtr(iai); TCHAR strDescription[512]; DXUtil_ConvertAnsiStringToGenericCch( strDescription, pAdapterInfo->AdapterIdentifier.Description, 512 ); ComboBoxAdd( IDC_ADAPTER_COMBO, pAdapterInfo, strDescription ); if( pAdapterInfo->AdapterOrdinal == m_d3dSettings.AdapterOrdinal() ) ComboBoxSelect( IDC_ADAPTER_COMBO, pAdapterInfo ); } if( !ComboBoxSomethingSelected( IDC_ADAPTER_COMBO ) && ComboBoxCount( IDC_ADAPTER_COMBO ) > 0 ) { ComboBoxSelectIndex( IDC_ADAPTER_COMBO, 0 ); } } return TRUE; case WM_COMMAND: switch( LOWORD(wParam) ) { case IDOK: EndDialog( hDlg, IDOK ); break; case IDCANCEL: EndDialog( hDlg, IDCANCEL ); break; case IDC_ADAPTER_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) AdapterChanged(); break; case IDC_DEVICE_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) DeviceChanged(); break; case IDC_ADAPTERFORMAT_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) AdapterFormatChanged(); break; case IDC_RESOLUTION_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) ResolutionChanged(); break; case IDC_REFRESHRATE_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) RefreshRateChanged(); break; case IDC_BACKBUFFERFORMAT_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) BackBufferFormatChanged(); break; case IDC_DEPTHSTENCILBUFFERFORMAT_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) DepthStencilBufferFormatChanged(); break; case IDC_MULTISAMPLE_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) MultisampleTypeChanged(); break; case IDC_MULTISAMPLE_QUALITY_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) MultisampleQualityChanged(); break; case IDC_VERTEXPROCESSING_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) VertexProcessingChanged(); break; case IDC_PRESENTINTERVAL_COMBO: if( CBN_SELCHANGE == HIWORD(wParam) ) PresentIntervalChanged(); break; case IDC_WINDOW: case IDC_FULLSCREEN: WindowedFullscreenChanged(); break; } return TRUE; default: return FALSE; } }