home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / appgray.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  57 lines

  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.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_INIT_SEG
  14. #pragma code_seg(AFX_INIT_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // Support for gray background in dialogs (and message boxes)
  24.  
  25. #ifndef _AFX_NO_GRAYDLG_SUPPORT
  26.  
  27. LRESULT CALLBACK
  28. _AfxCbtFilterHook(int code, WPARAM wParam, LPARAM lParam);
  29.  
  30. void CWinApp::SetDialogBkColor(COLORREF clrCtlBk, COLORREF clrCtlText)
  31. {
  32.     if (!afxContextIsDLL)
  33.     {
  34.         _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
  35.         if (pThreadState->m_hHookOldCbtFilter == NULL)
  36.         {
  37.             pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT,
  38.                 _AfxCbtFilterHook, NULL, ::GetCurrentThreadId());
  39.             if (pThreadState->m_hHookOldCbtFilter == NULL)
  40.                 AfxThrowMemoryException();
  41.         }
  42.     }
  43.  
  44.     // set up for gray backgrounds for dialogs
  45.     _AFX_WIN_STATE* pWinState = _afxWinState;
  46.     AfxDeleteObject((HGDIOBJ*)&pWinState->m_hDlgBkBrush);
  47.  
  48.     pWinState->m_hDlgBkBrush = ::CreateSolidBrush(clrCtlBk);
  49.     pWinState->m_crDlgTextClr = clrCtlText;
  50.     if (pWinState->m_hDlgBkBrush == NULL)
  51.         AfxThrowResourceException();
  52. }
  53.  
  54. #endif //!_AFX_NO_GRAYDLG_SUPPORT
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57.