appgray.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #ifdef AFX_INIT_SEG
  12. #pragma code_seg(AFX_INIT_SEG)
  13. #endif
  14. #ifdef _DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // Support for gray background in dialogs (and message boxes)
  20. #ifndef _AFX_NO_GRAYDLG_SUPPORT
  21. LRESULT CALLBACK
  22. _AfxCbtFilterHook(int code, WPARAM wParam, LPARAM lParam);
  23. void CWinApp::SetDialogBkColor(COLORREF clrCtlBk, COLORREF clrCtlText)
  24. {
  25. if (!afxContextIsDLL)
  26. {
  27. _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
  28. if (pThreadState->m_hHookOldCbtFilter == NULL)
  29. {
  30. pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT,
  31. _AfxCbtFilterHook, NULL, ::GetCurrentThreadId());
  32. if (pThreadState->m_hHookOldCbtFilter == NULL)
  33. AfxThrowMemoryException();
  34. }
  35. }
  36. // set up for gray backgrounds for dialogs
  37. _AFX_WIN_STATE* pWinState = _afxWinState;
  38. AfxDeleteObject((HGDIOBJ*)&pWinState->m_hDlgBkBrush);
  39. pWinState->m_hDlgBkBrush = ::CreateSolidBrush(clrCtlBk);
  40. pWinState->m_crDlgTextClr = clrCtlText;
  41. if (pWinState->m_hDlgBkBrush == NULL)
  42. AfxThrowResourceException();
  43. }
  44. #endif //!_AFX_NO_GRAYDLG_SUPPORT
  45. /////////////////////////////////////////////////////////////////////////////