Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

  1. #ifndef _CWNDPROC_H_
  2. #define _CWNDPROC_H_
  3. // CImpWndProc
  4. //
  5. // Use this class when you want to associate a window with
  6. // an object using a virtual wndproc.
  7. //
  8. // NOTE: The window's lifetime must be encompassed by the object.
  9. // I.E. NO REFCOUNT IS HELD ON THE OBJECT!
  10. //
  11. // Messages after WM_NCCREATE up to and including WM_DESTROY
  12. // are forwarded to v_WndProc.
  13. //
  14. // _hwnd is non-NULL from WM_NCCREATE up to but not during WM_DESTROY.
  15. // (Not during because the final release may be tied to WM_DESTROY
  16. // so we cannot reference member variables after forwarding thie message.)
  17. //
  18. class CImpWndProc
  19. {
  20. public:
  21. virtual ULONG __stdcall AddRef() = 0;
  22. virtual ULONG __stdcall Release() = 0;
  23. protected:
  24. virtual LRESULT v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PURE;
  25. static LRESULT CALLBACK s_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  26. HWND _hwnd;
  27. } ;
  28. // CNotifySubclassWndProc
  29. //
  30. // This class subclasses an HWND, registers for SHChangeNotify events,
  31. // and forwards them to the inheritor's IShellChangeNotify implementation.
  32. //
  33. // You need one instance of this class per window you want to subclass
  34. // and register for events against. (So if you need >1 window hooked up
  35. // in this matter, you need to have member implementations that inherit
  36. // from this class.)
  37. //
  38. class CNotifySubclassWndProc
  39. {
  40. public:
  41. virtual STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) PURE;
  42. protected:
  43. BOOL _SubclassWindow(HWND hwnd);
  44. void _UnsubclassWindow(HWND hwnd);
  45. void _RegisterWindow(HWND hwnd, LPCITEMIDLIST pidl, long lEvents,
  46. UINT uFlags = (SHCNRF_ShellLevel | SHCNRF_InterruptLevel));
  47. void _UnregisterWindow(HWND hwnd);
  48. virtual LRESULT _DefWindowProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  49. void _FlushNotifyMessages(HWND hwnd);
  50. private:
  51. static LRESULT CALLBACK _SubclassWndProc(
  52. HWND hwnd, UINT uMessage,
  53. WPARAM wParam, LPARAM lParam,
  54. UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
  55. UINT _uRegister; // SHChangeNotify id
  56. #ifdef DEBUG
  57. HWND _hwndSubclassed;
  58. #endif
  59. } ;
  60. #endif _CWNDPROC_H_