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.

82 lines
1.9 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: cm_misc.h
  4. //
  5. // Module: CMDIAL32.DLL
  6. //
  7. // Synopsis: Implements the CFreezeWindow Class
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: henryt Created 01/13/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef _CM_MISC_INC
  15. #define _CM_MISC_INC
  16. extern HINSTANCE g_hInst; // the instance handle for resource
  17. //
  18. // A helper class to auto disable/enable window
  19. // The constructor will disable the window, the distructor will enable the window
  20. //
  21. class CFreezeWindow
  22. {
  23. public:
  24. CFreezeWindow(HWND hWnd, BOOL fDisableParent = FALSE)
  25. {
  26. //
  27. // Disable the window
  28. // To disable a property page, the property sheet also need to be disabled
  29. //
  30. m_hWnd = hWnd;
  31. if (m_hWnd)
  32. {
  33. m_fDisableParent = fDisableParent;
  34. //
  35. // Store the currently focuse window
  36. //
  37. m_hFocusWnd = GetFocus();
  38. EnableWindow(m_hWnd, FALSE);
  39. if (fDisableParent)
  40. {
  41. EnableWindow(GetParent(m_hWnd), FALSE);
  42. }
  43. }
  44. }
  45. ~CFreezeWindow()
  46. {
  47. if (m_hWnd)
  48. {
  49. EnableWindow(m_hWnd, TRUE);
  50. if (m_fDisableParent)
  51. {
  52. EnableWindow(GetParent(m_hWnd), TRUE);
  53. }
  54. //
  55. // Restore focus to the previously focuses window if any.
  56. // Its just the right thing to do.
  57. //
  58. if (m_hFocusWnd)
  59. {
  60. SetFocus(m_hFocusWnd);
  61. }
  62. }
  63. }
  64. protected:
  65. HWND m_hWnd;
  66. HWND m_hFocusWnd;
  67. BOOL m_fDisableParent;
  68. };
  69. #endif