AlphaBlend.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // AlphaBlend.h: interface for the CAlphaBlend class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. // By Mike Ryan ([email protected])
  5. // Copyright (c) 2000
  6. // 07.03.2000
  7. //
  8. // Free usage granted in all applications including commercial.
  9. // Do NOT distribute without permission from me. I can be reached
  10. // at [email protected], http://www.codexia.com
  11. // Please feel free to email me about this class.
  12. //
  13. // NOTE:
  14. //
  15. // You will need the latest Win32 API availble at:
  16. // http://msdn.microsoft.com/downloads/c-frame.htm?007#/downloads/sdks/
  17. // in order to compile this programs.
  18. //
  19. // This will only run under Windows 2000. It is not compatible with
  20. // Windows 9x or Windows NT 4.0.
  21. //
  22. // Also, you must add the following lines to the StdAfx.h at the top
  23. // above the #define VC_EXTRALEAN.
  24. //
  25. // #define _WIN32_WINNT 0x0500
  26. // #define WINVER 0x0500
  27. //
  28. //////////////////////////////////////////////////////////////////////
  29. #if !defined(AFX_ALPHABLEND_H__B453CE58_5571_48B4_BD84_3BB70D6A41A3__INCLUDED_)
  30. #define AFX_ALPHABLEND_H__B453CE58_5571_48B4_BD84_3BB70D6A41A3__INCLUDED_
  31. #if _MSC_VER > 1000
  32. #pragma once
  33. #endif // _MSC_VER > 1000
  34. #define OPACITY_MAX 255
  35. class CAlphaBlend
  36. {
  37. public:
  38. CAlphaBlend();
  39. CAlphaBlend(HWND hWnd, int nOpacity=220);
  40. CAlphaBlend(CWnd *pWnd, int nOpacity=220);
  41. virtual ~CAlphaBlend();
  42. //// SET DATA MEMBERS ////
  43. BOOL SetWindowHandle(HWND hWnd);
  44. BOOL SetWindowHandle(CWnd *pWnd);
  45. BOOL SetOpacity(int nOpacity=220);
  46. //// RUN IT ////
  47. void SetTransparent(BOOL bTransparent=true);
  48. //// FOR THOSE OF US WHO ARE LAZY ////
  49. BOOL SetTransparent(HWND hWnd, int nOpactiy=220, BOOL bTransparent=true);
  50. //// GET TRANSPARENT/OPACITY STATUS ////
  51. int GetOpacity(void) { return m_nOpacity; }
  52. HWND GetWindow(void) { return m_hWnd; }
  53. BOOL IsTransparent(void) { return m_bTransparent; }
  54. protected:
  55. int m_nOpacity;
  56. HWND m_hWnd;
  57. BOOL m_bTransparent;
  58. BOOL SetLayeredWindowAttributesEx(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
  59. };
  60. #endif // !defined(AFX_ALPHABLEND_H__B453CE58_5571_48B4_BD84_3BB70D6A41A3__INCLUDED_)