1
0

skinnedwnd.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef NULLOSFT_MEDIALIBRARY_SKINNED_WINDOW_HEADER
  2. #define NULLOSFT_MEDIALIBRARY_SKINNED_WINDOW_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <windows.h>
  7. #include "./ml.h"
  8. #include "./ml_ipc_0313.h"
  9. #include "./reflectmsg.h"
  10. #include "./stockobjects.h"
  11. #define MLWM_SKINCHANGED (WM_APP + 0x2FFF)
  12. #define BORDER_NONE 0
  13. #define BORDER_SUNKEN 1
  14. #define BORDER_FLAT 2
  15. typedef enum SkinnedWndRedraw
  16. {
  17. SWR_NONE = 0,
  18. SWR_INVALIDATE = (1 << 0),
  19. SWR_ERASE = (1 << 1),
  20. SWR_UPDATE = (1 << 2),
  21. SWR_ALLCHILDREN = (1 << 3),
  22. }SkinnedWndRedraw;
  23. DEFINE_ENUM_FLAG_OPERATORS(SkinnedWndRedraw);
  24. class SkinnedWnd
  25. {
  26. protected:
  27. SkinnedWnd(BOOL bIsDialog);
  28. virtual ~SkinnedWnd(void);
  29. public:
  30. static SkinnedWnd *GetFromHWND(HWND hwndSkinned);
  31. static BOOL IsDwmCompositionEnabled();
  32. BOOL IsUnicode(void);
  33. BOOL IsAttached(void);
  34. INT GetType(void) { return (INT)LOWORD(wnddata); }
  35. HWND GetHWND(void) { return hwnd; }
  36. void SkinChanged(BOOL bNotifyChildren, BOOL bRedraw);
  37. void EnableReflection(BOOL bEnable);
  38. virtual BOOL SetStyle(UINT newStyle, BOOL bRedraw);
  39. virtual UINT GetStyle(void) { return style; }
  40. void SetMinMaxInfo(MLSKINNEDMINMAXINFO *minMax);
  41. protected:
  42. virtual BOOL Attach(HWND hwndToSkin);
  43. void SetType(INT newType) { ((wnddata & 0xFFFF0000) | (newType & 0xFFFF)); }
  44. LRESULT CallPrevWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  45. LRESULT CallDefWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  46. virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  47. virtual void OnSkinChanged(BOOL bNotifyChildren, BOOL bRedraw);
  48. virtual void OnSkinUpdated(BOOL bNotifyChildren, BOOL bRedraw);
  49. virtual BOOL OnMediaLibraryIPC(INT msg, INT_PTR param, LRESULT *pResult);
  50. virtual INT OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS *pncsp);
  51. virtual INT OnNcHitTest(POINTS pts);
  52. virtual void OnNcPaint(HRGN rgnUpdate);
  53. virtual void OnPrint(HDC hdc, UINT options);
  54. virtual void DrawBorder(HDC hdc);
  55. virtual void OnDwmCompositionChanged(void);
  56. virtual UINT GetBorderType(void);
  57. virtual HPEN GetBorderPen(void);
  58. void OnUpdateUIState(UINT uAction, UINT uState);
  59. virtual void OnStyleChanged(INT styleType, STYLESTRUCT *pss);
  60. void DisableRedraw();
  61. void EnableRedraw(SkinnedWndRedraw redrawFlags);
  62. virtual BOOL OnDirectMouseWheel(INT delta, UINT vtKey, POINTS pts);
  63. virtual void OnGetMinMaxInfo(MINMAXINFO *minMax);
  64. public:
  65. static void DrawBorder(HDC hdc, RECT *prc, UINT type, HPEN pen);
  66. private:
  67. static LRESULT WINAPI WindowProcReal(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  68. friend BOOL SkinWindowEx(HWND hwndToSkin, INT type, UINT style);
  69. friend BOOL UnskinWindow(HWND hwndToUnskin);
  70. protected:
  71. HWND hwnd;
  72. UINT style;
  73. WORD uiState;
  74. ULONG redrawLock;
  75. SIZE minSize;
  76. SIZE maxSize;
  77. private:
  78. WNDPROC fnWndProc;
  79. LONG wnddata;
  80. };
  81. #endif // NULLOSFT_MEDIALIBRARY_SKINNED_WINDOW_HEADER