CFolderDialog::~CFolderDialog(VOID) { SAFE_COTASKMEMFREE(m_bi.pidlRoot); SAFE_DELETE2(m_bi.pszDisplayName); ::ZeroMemory(&m_bi, sizeof(BROWSEINFO)); }
BOOL CFolderDialog::SetRootFolder(IN LPCTSTR pszPath) { ASSERT_VALID(this); if (!pszPath) { SAFE_COTASKMEMFREE(m_bi.pidlRoot); return TRUE; } ASSERT(AfxIsValidString(pszPath, MAX_PATH)); HRESULT hResult = S_FALSE; IShellFolder* pDeskFolder = NULL; hResult = ::SHGetDesktopFolder(&pDeskFolder); if (hResult == S_OK) { LPITEMIDLIST pidlRoot = NULL; LPTSTR pszRoot = const_cast< LPTSTR >(pszPath); // Convert the path to an ITEMIDLIST: USES_CONVERSION; hResult = pDeskFolder->ParseDisplayName( NULL, NULL, T2W(pszRoot), NULL, &pidlRoot, NULL ); if (hResult == S_OK) { SAFE_COTASKMEMFREE(m_bi.pidlRoot); m_bi.pidlRoot = pidlRoot; } SAFE_RELEASE(pDeskFolder); } return (hResult == S_OK); }
INT CFolderDialog::DoModal(VOID) #endif { ASSERT_VALID(this); ASSERT(m_bi.lpfn != NULL); INT_PTR nRet = -1; m_bi.hwndOwner = PreModal(); LPITEMIDLIST pItemIDList = ::SHBrowseForFolder(&m_bi); if (pItemIDList) { if (::SHGetPathFromIDList(pItemIDList, m_szFolPath)) nRet = IDOK; SAFE_COTASKMEMFREE(pItemIDList); } else nRet = IDCANCEL; PostModal(); return (nRet); }
// ---------------------------------------------------------------------------- // Function: // CSwapPropPage::OnInitDialog // // Description: // Dialog initialization routine // // Parameters: // hwndDlg - [in] Handle to dialog box // wParam - [in] Handle to control to receive the default keyboard focus // lParam - [in] Specifies additional message-specific information // // Return values: // TRUE to direct the system to set the keyboard focus to the control // specified by wParam. Otherwise, it should return FALSE to prevent the // system from setting the default keyboard focus. // ---------------------------------------------------------------------------- BOOL CSwapPropPage::OnInitDialog ( HWND hwndDlg, WPARAM wParam, LPARAM lParam ) { UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam); HRESULT hr = S_OK; LPWSTR pwstrEndpointName = NULL; // Retrieve the endpoint's friendly name, system effects, and swap SFX and MFX states hr = GetDeviceFriendlyName(&pwstrEndpointName); IF_FAILED_JUMP(hr, Exit); hr = RetrieveSysFXState(&m_fDisableSysFX); IF_FAILED_JUMP(hr, Exit); hr = RetrieveSwapSFXState(&m_fEnableSwapSFX); IF_FAILED_JUMP(hr, Exit); hr = RetrieveSwapMFXState(&m_fEnableSwapMFX); IF_FAILED_JUMP(hr, Exit); hr = RetrieveDelaySFXState(&m_fEnableDelaySFX); IF_FAILED_JUMP(hr, Exit); hr = RetrieveDelayMFXState(&m_fEnableDelayMFX); IF_FAILED_JUMP(hr, Exit); // Update the property page with retrieved information SetWindowText(GetDlgItem(hwndDlg, IDC_SPP_ENDPOINT_NAME), pwstrEndpointName); // Based on the retrieved states, toggle the checkboxes to reflect them if (m_fDisableSysFX) { CheckDlgButton(hwndDlg, IDC_DISABLE_SYSFX, BST_CHECKED); // Disable APO toggling controls on the page EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), FALSE); } else { CheckDlgButton(hwndDlg, IDC_DISABLE_SYSFX, BST_UNCHECKED); // Enable APO toggling controls on the page EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), TRUE); } if (m_fEnableSwapSFX) { CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_SFX, BST_CHECKED); } else { CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_SFX, BST_UNCHECKED); } if (m_fEnableSwapMFX) { CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_MFX, BST_CHECKED); } else { CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_MFX, BST_UNCHECKED); } if (m_fEnableDelaySFX) { CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_SFX, BST_CHECKED); } else { CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_SFX, BST_UNCHECKED); } if (m_fEnableDelayMFX) { CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_MFX, BST_CHECKED); } else { CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_MFX, BST_UNCHECKED); } Exit: SAFE_COTASKMEMFREE(pwstrEndpointName); return(FALSE); }