void CPage6::OnDestroy() { if (m_ulChangeIconNotifyID != 0) { SHChangeNotifyDeregister(m_ulChangeIconNotifyID); } CMFCPropertyPage::OnDestroy(); }
void CRecBinViewer::RemoveShellNotify () { int iPos = 0; while (iPos < _countof (m_pidlDrives)) { if (NULL != m_hNotifyDrives[iPos]) { SHChangeNotifyDeregister(m_hNotifyDrives[iPos]); } if (NULL != m_pidlDrives[iPos]) { CoTaskMemFree (m_pidlDrives[iPos]); } iPos ++; } ZeroMemory (&m_pidlDrives, sizeof (m_pidlDrives)); ZeroMemory (&m_hNotifyDrives, sizeof (m_hNotifyDrives)); }
/// <summary> /// Destructor /// </summary> TileGroup::~TileGroup() { if (mChangeNotifyUID != 0) { SHChangeNotifyDeregister(mChangeNotifyUID); } if (mChangeNotifyMsg) { mWindow->ReleaseUserMessage(mChangeNotifyMsg); } if (mIconLoadedMessage) { mWindow->ReleaseUserMessage(mIconLoadedMessage); } for (auto tile : mTiles) { delete tile; } SAFERELEASE(mWorkingFolder); SAFERELEASE(mRootFolder); }
/// <summary> /// /// </summary> void TileGroup::SetFolder(LPWSTR folder) { PIDLIST_ABSOLUTE idList; // Just in case we are switching folders, deregister for old notifications if (mChangeNotifyUID != 0) { SHChangeNotifyDeregister(mChangeNotifyUID); mChangeNotifyUID = 0; } // Get the folder we are interested in if (_wcsicmp(folder, L"desktop") == 0) { SHGetKnownFolderIDList(FOLDERID_Desktop, 0, nullptr, &idList); SHGetDesktopFolder(reinterpret_cast<IShellFolder**>(&mWorkingFolder)); } else { mRootFolder->ParseDisplayName(nullptr, nullptr, folder, nullptr, &idList, nullptr); mRootFolder->BindToObject(idList, nullptr, IID_IShellFolder, reinterpret_cast<LPVOID*>(&mWorkingFolder)); } // Enumerate the contents of this folder LoadFolderRequest request; request.blackList = mHiddenItems; request.folder = mWorkingFolder; request.targetIconWidth = mTileSettings.mIconSize; nCore::LoadFolder(request, this); // Register for change notifications SHChangeNotifyEntry watchEntries[] = { idList, FALSE }; mChangeNotifyUID = SHChangeNotifyRegister( mWindow->GetWindowHandle(), CHANGE_SOURCES, CHANGE_EVENTS, mChangeNotifyMsg, 1, watchEntries); // Let go fo the PIDLists CoTaskMemFree(idList); }
void CRecBinViewer::RemoveRBinNotify () { SHChangeNotifyDeregister(m_hNotifyRBin); }
/************************************************************************* * NTSHChangeNotifyDeregister [SHELL32.641] */ EXTERN_C DWORD WINAPI NTSHChangeNotifyDeregister(ULONG x1) { FIXME("(0x%08x):semi stub.\n",x1); return SHChangeNotifyDeregister( x1 ); }
/// <summary> /// Handles window messages. /// </summary> LRESULT WINAPI TileGroup::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam, LPVOID) { if (message == mChangeNotifyMsg) { return HandleChangeNotify(HANDLE(wParam), DWORD(lParam)); } if (mContextMenu3) { LRESULT result; if (SUCCEEDED(mContextMenu3->HandleMenuMsg2(message, wParam, lParam, &result))) { return result; } } if (mContextMenu2) { if (SUCCEEDED(mContextMenu2->HandleMenuMsg(message, wParam, lParam))) { return 0; } } switch (message) { case WM_KEYDOWN: switch (wParam) { case 'A': if (GetKeyState(VK_CONTROL) < 0) { SelectAll(); } break; case 'C': if (GetKeyState(VK_CONTROL) < 0) { DoCopy(false); } break; case 'V': if (GetKeyState(VK_CONTROL) < 0) { DoPaste(); } break; case 'X': if (GetKeyState(VK_CONTROL) < 0) { DoCopy(true); } break; case 'Z': if (GetKeyState(VK_CONTROL) < 0) { DoUndo(); } break; case VK_DELETE: DeleteSelectedFiles(); break; case VK_RETURN: OpenSelectedFiles(); break; case VK_F2: RenameSelectedFiles(); break; case VK_F5: UpdateAllIcons(); break; case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT: break; } break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: if (!mInRectangleSelection) { StartRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else { EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } break; case WM_MOUSEMOVE: if (mInRectangleSelection) { MoveRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } break; case WM_LBUTTONUP: case WM_RBUTTONUP: if (mInRectangleSelection) { EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if (GetKeyState(VK_CONTROL) >= 0) { DeselectAll(); } break; case Window::WM_TOPPARENTLOST: mChangeNotifyMsg = 0; if (mChangeNotifyUID != 0) { SHChangeNotifyDeregister(mChangeNotifyUID); mChangeNotifyUID = 0; } break; case Window::WM_NEWTOPPARENT: { // TODO(Erik): This is unacceptable. We have to pick up change notifications while we don't // have a top parent. IPersistFolder2 *ipsf2; LPITEMIDLIST curFolder; HRESULT hr; mChangeNotifyMsg = mWindow->RegisterUserMessage(this); if (SUCCEEDED(hr = mWorkingFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&ipsf2))) { if (SUCCEEDED(hr = ipsf2->GetCurFolder(&curFolder))) { // (Re)Register for change notifications SHChangeNotifyEntry watchEntries[] = { curFolder, FALSE }; mChangeNotifyUID = SHChangeNotifyRegister( window, CHANGE_SOURCES, CHANGE_EVENTS, mChangeNotifyMsg, 1, watchEntries); // Let go fo the PIDLists CoTaskMemFree(curFolder); } ipsf2->Release(); } } break; } mEventHandler->HandleMessage(window, message, wParam, lParam); return DefWindowProc(window, message, wParam, lParam); }
monitor::~monitor() { if (!m_notifyId) SHChangeNotifyDeregister(m_notifyId); }