BOOL CNoticeDlg::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem(IDOK)->EnableWindow(false);//显示确定按钮无效 SetAdapter();//获得网卡信息 return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
////////////////////////////////////////////////////////////////////////////////////////// // // CSettingsSA::SetValidVideoMode // // Set/validate the required video mode // ////////////////////////////////////////////////////////////////////////////////////////// void CSettingsSA::SetValidVideoMode( void ) { bool bValid = false; int iWidth, iHeight, iColorBits, iAdapterIndex; bool bAllowUnsafeResolutions = false; // First, try to get MTA saved info if ( !bValid ) { bValid = g_pCore->GetRequiredDisplayResolution( iWidth, iHeight, iColorBits, iAdapterIndex, bAllowUnsafeResolutions ); } // Otherwise deduce from GTA saved video mode if ( !bValid ) { SetAdapter( 0 ); uint numVidModes = GetNumVideoModes(); if ( VAR_SavedVideoMode > 0 && VAR_SavedVideoMode < numVidModes ) { VideoMode modeInfo; if ( GetVideoModeInfo( &modeInfo, VAR_SavedVideoMode ) ) { iWidth = modeInfo.width; iHeight = modeInfo.height; iColorBits = modeInfo.depth; iAdapterIndex = 0; bValid = true; } } } // Finally use default if ( !bValid ) { bValid = true; iWidth = 800; iHeight = 600; iColorBits = 32; iAdapterIndex = 0; } // Set adapter if ( (uint)iAdapterIndex >= GetNumAdapters() ) iAdapterIndex = 0; SetAdapter( iAdapterIndex ); // Save desktop resolution { m_iDesktopWidth = 800; m_iDesktopHeight = 600; VideoMode currentModeInfo; if ( GetVideoModeInfo( ¤tModeInfo, GetCurrentVideoMode() ) ) { m_iDesktopWidth = currentModeInfo.width; m_iDesktopHeight = currentModeInfo.height; } } // Handle 'unsafe' resolution stuff if ( IsUnsafeResolution( iWidth, iHeight ) ) { if ( bAllowUnsafeResolutions ) { // Confirm that res should be used SString strMessage = _("Are you sure you want to use this screen resolution?" ); strMessage += SString( "\n\n%d x %d", iWidth, iHeight ); if ( MessageBoxUTF8( NULL, strMessage, _("MTA: San Andreas"), MB_YESNO | MB_TOPMOST | MB_ICONQUESTION ) == IDNO ) bAllowUnsafeResolutions = false; } if ( !bAllowUnsafeResolutions ) { // Force down to desktop res if required iWidth = m_iDesktopWidth; iHeight = m_iDesktopHeight; } } // Ensure res is no smaller than 640 x 480 iWidth = Max( 640, iWidth ); iHeight = Max( 480, iHeight ); // Find mode number which best matches required settings uint uiUseVideoMode = FindVideoMode( iWidth, iHeight, iColorBits ); // Set for GTA to use VAR_CurVideoMode = uiUseVideoMode; VAR_SavedVideoMode = uiUseVideoMode; VAR_CurAdapter = iAdapterIndex; }
BOOL NetmonProfile::Load(const TCHAR *szDefaultAdapter) { TCHAR szCurrentExe[MAX_PATH]={ 0 }; TCHAR szCurrentDir[MAX_PATH]={ 0 }; TCHAR szProfile[MAX_PATH]={ 0 }; TCHAR *pFilePart; TCHAR szHiddenProcesses[1000]; // Get full path name of Netmon.exe GetModuleFileName(0, szCurrentExe, MAX_PATH); // Get base directory GetFullPathName(szCurrentExe, MAX_PATH, szCurrentDir, &pFilePart); *pFilePart = TEXT('\0'); // Get full path name of Netmon.ini _tcscpy_s(szProfile, MAX_PATH, szCurrentDir); _tcscat_s(szProfile, MAX_PATH, _T("Netmon.ini")); // Init _pf.Init(szProfile, _T("Netmon Profile v1")); // Load preferences // If the key doesn't exist, a default value is written to the ini file if( _pf.GetString(_T("Adapter"), _szAdapter, 256) == FALSE ) { SetAdapter(szDefaultAdapter); } if( _pf.GetString(_T("AutoStart"), _szAutoStart, MAX_PATH) == FALSE ) { SetAutoStart(_T("")); } if( _pf.GetInt(_T("AutoCapture"), &_bAutoCapture) == FALSE ) { SetAutoCapture(FALSE); } if( _pf.GetInt(_T("DtViewEnable"), &_bDtViewEnable) == FALSE ) { SetDtViewEnable(FALSE); } if( _pf.GetInt(_T("DtViewMaxSpace"), &_iDtViewMaxSpace) == FALSE ) { SetDtViewMaxSpace(0); // No limit } if( _pf.GetString(_T("HiddenProcess"), szHiddenProcesses, 1000) == FALSE) { SetHiddenProcesses(std::vector<int>()); } else { int puid; int offset = 0; while (_stscanf_s(szHiddenProcesses + offset, _T("%d"), &puid) == 1) { _hiddenProcesses.push_back(puid); // Offset TCHAR buf[16]; _stprintf_s(buf, 16, _T("%d"), puid); offset += _tcslen(buf) + 1; } } if( _pf.GetString(_T("Language"), _szLanguage, 64) == FALSE ) { SetLanguage(_T("English")); } if( _pf.GetInt(_T("ShowHidden"), &_bShowHidden) == FALSE ) { SetShowHidden(TRUE); } return TRUE; }