SuppressStyle.h
上传用户:kssdz899
上传日期:2007-01-08
资源大小:79k
文件大小:1k
源码类别:

钩子与API截获

开发平台:

Visual C++

  1. #ifndef SUPPRESS_STYLE_H
  2. #define SUPPRESS_STYLE_H
  3. ///////////////////////////
  4. //
  5. // Objects of this class will suppress a window style
  6. //  from construction until destruction.
  7. //
  8. // Author: Dave Lorde (dlorde@cix.compulink.co.uk)
  9. //
  10. //          Copyright January 2000
  11. //
  12. class AFX_EXT_CLASS SuppressStyle
  13. {
  14. public:
  15. SuppressStyle(HWND hWnd, DWORD style)
  16. :m_hWnd(hWnd), m_Style(style), m_OldStyle(0)
  17. {
  18. m_OldStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
  19. if (m_OldStyle & m_Style)
  20. SetWindowLong(m_hWnd, GWL_STYLE, m_OldStyle & ~m_Style); 
  21. }
  22. ~SuppressStyle()
  23. {
  24. if (m_OldStyle & m_Style)
  25. SetWindowLong(m_hWnd, GWL_STYLE, m_OldStyle);
  26. }
  27. private:
  28. DWORD m_Style;
  29. DWORD m_OldStyle;
  30. HWND  m_hWnd;
  31. };
  32. #endif