Leaked source code of windows server 2003
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.

100 lines
2.4 KiB

  1. /*
  2. * PIDLButton header
  3. */
  4. namespace DirectUI
  5. {
  6. // Class definition
  7. class PIDLButton : public Button
  8. {
  9. public:
  10. static HRESULT Create(OUT Element** ppElement) { return Create(NULL, AE_MouseAndKeyboard, ppElement); }
  11. static HRESULT Create(LPITEMIDLIST pidl, OUT Element** ppElement) { return Create(pidl, AE_MouseAndKeyboard, ppElement); }
  12. static HRESULT Create(LPITEMIDLIST pidl, UINT nActive, OUT Element** ppElement);
  13. static void SetImageSize(int nImageSize) { s_nImageSize = nImageSize; }
  14. // System events
  15. virtual void OnPropertyChanged(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  16. virtual void OnEvent(Event* pEvent);
  17. virtual void OnInput(InputEvent* pie);
  18. HRESULT OnContextMenu(POINT *ppt);
  19. LRESULT OnMenuMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  20. HRESULT Initialize(LPITEMIDLIST pidl, UINT nActive);
  21. HRESULT InvokePidl();
  22. /*
  23. * Message exchanged with host to handle IContextMenu2 and IContextMenu3
  24. */
  25. enum {
  26. PBM_SETMENUFORWARD = WM_USER + 1 // WM_USER is used by DirectUI
  27. };
  28. // Property definitions
  29. // ClassInfo accessors (static and virtual instance-based)
  30. static IClassInfo* Class;
  31. virtual IClassInfo* GetClassInfo() { return Class; }
  32. virtual HRESULT Register();
  33. PIDLButton() { };
  34. protected:
  35. virtual ~PIDLButton();
  36. HWNDElement *GetHWNDHost()
  37. {
  38. if (!_peHost)
  39. {
  40. Element *pe = GetRoot();
  41. if (pe && pe->GetClassInfo()->IsSubclassOf(HWNDElement::Class))
  42. {
  43. _peHost = reinterpret_cast<HWNDElement *>(pe);
  44. }
  45. }
  46. return _peHost;
  47. }
  48. HWND GetHWND()
  49. {
  50. HWNDElement *phe = GetHWNDHost();
  51. if (phe)
  52. {
  53. return phe->GetHWND();
  54. }
  55. return NULL;
  56. }
  57. /*
  58. * Custom commands we add to the context menu.
  59. */
  60. enum {
  61. // none yet
  62. IDM_QCM_MIN = 0x0100,
  63. IDM_QCM_MAX = 0x7FFF,
  64. };
  65. private:
  66. LPITEMIDLIST _pidl;
  67. static int s_nImageSize;
  68. // Caching host information
  69. HWNDElement * _peHost;
  70. //
  71. // Context menu handling
  72. //
  73. IContextMenu2 * _pcm2Pop; /* Currently popped-up context menu */
  74. IContextMenu3 * _pcm3Pop; /* Currently popped-up context menu */
  75. };
  76. } // namespace DirectUI